How to set date format in drupal 8 for date time field?
In Drupal 8, the date format and time format are separated. The values for this has to be set separately.

I found this by creating new cck field in a content type and printing it from form alter.

$date_format = 'Y-m-d'; $time_format = 'H:i';

$form['start_date'] = [
      '#type' =&gt; 'datetime',
      '#title' =&gt; t('Start Date'),
      '#date_date_format' =&gt; $date_format,
      '#date_time_format' =&gt; $time_format,
      '#description' =&gt; date($date_format, time()),
      '#default_value' =&gt; Drupal\Core\Datetime\DrupalDateTime::createFromTimestamp(time())
    ];