title: How to write datetime field to apex database?
body: <p>I created a field with the datime type, I write data to the database from it, but an empty field is written, how to write down the date that I fill in the form?</p>
  <pre><code> &lt;lightning-input class=&quot;date-area&quot; type=&quot;datetime&quot; format=&quot;MM/dd/yyyy&quot; name=&quot;date&quot; label=&quot;Select date&quot;
                          onchange={handleDateChange} required&gt;&lt;/lightning-input&gt; 
  
  handleDateChange(event) {
          this.date = event.target.value;
          console.log(&quot;Date&quot;, this.date);
      }
  </code></pre>
  <p>public with sharing class TestDriveController {
  public TestDriveController() {</p>
  <pre><code>}
  @AuraEnabled
  public static Boolean createApplicationTestDrive(String firstname, String lastname, String phone, String email, String carCenter, String product, String text, Datetime data){
      Test_Drive__c testDrive = TestDriveService.createApplicationTestDrive(firstname, lastname, phone, email, carCenter, product, text, data);
      return true;
  }
  </code></pre>
  <p>}</p>
  <pre><code>public with sharing class TestDriveService {
      public TestDriveService() {
  
      }
      public static Datetime formDatetimeFromStringGTM2(String dateToForm) {
          if (!String.isBlank(dateToForm)) {
              String  correctDate =  dateToForm.replace('T', ' ');
              return correctDate;
          }
          return null;
      }
      public static Test_Drive__c createApplicationTestDrive(String firstname, String lastname, String phone, String email, String carCenter, String product, String text, Datetime data){
          Datetime  correctDate = formDatetimeFromStringGTM2(data);
          return TestDriveManager.createApplicationTestDrive(firstname, lastname, phone, email, carCenter, product, text, correctDate);
      }
  }
  
  public with sharing class TestDriveManager {
      public TestDriveManager() {
  
      }
      public static Test_Drive__c createApplicationTestDrive(String firstname, String lastname, String phone, String email, String carCenter, String product, String text, Datetime data){
          Test_Drive__c testDrive = new Test_Drive__c(
              First_Name__c = firstname,
              Last_Name__c = lastname,
              Phone__c = phone,
              Email__c = email,
              Car_Center__c = carCenter,
              Product__c = product,
              Text__c = text,
              Date__c = data
              
          );
          insert testDrive;
          return testDrive;
      }
  }
  </code></pre>