Custom form "Data too long for column" I create a custom entity (pool) with a custom form.

In my custom form, i have a field (start_date)

$form['start_date'] = [
  '#type' =&gt; 'datetime',
  '#title' =&gt; t('Start Date'),
  '#default_value' =&gt; new DrupalDateTime()
];


When i want to save, i have the follow error :

"Data too long for column"

In the log, the value is : 2017-12-21 18:06:29 Europe/Paris 
Instead of 2017-12-21T17:06:29 

What i'm doing wrong ?
Drupal's DateTime field isn't ISO 8601 compliant, (doesn't save datetime values in the standard format you're expecting 2017-12-21T17:06:29).  You need to convert the value to UTC format for storage.  One approach is to initialize a date variable, convert it, and then pass as the value in your form field.

$currentDate = new DrupalDateTime();
if ($currentDate instanceOf DrupalDateTime &amp;&amp; !$currentDate-&gt;hasErrors()) {
  $currentDate-&gt;setTimezone(new \DateTimeZone('UTC');
  $db_friendly_value = $currentDate-&gt;format('Y-m-d\TH:i:s');
}

$form['start_date'] = [
  '#type' =&gt; 'datetime',
  '#title' =&gt; t('Start Date'),
  '#default_value' =&gt; $db_friendly_value
];


Specific notes about working with the DateTime API in D8 can be found in this "New DateTime API" post.

This specific formatting issue was reported for the datetime module here.  

Comment 6 shows the recommended approach to converting the date into the proper format for saving.