How to set date format in drupal 8 for date time field? The default date format of drupal 8 is d.m.Y but I want it to be d-M-Y.

I have tried  

#format =&gt; 'd-m-Y'

#date_format =&gt; 'd-m-Y'

My date field

$form['start_date'] = [
           '#type' =&gt; 'datetime',
           '#title' =&gt; t('Start Date'),
           '#date_format' =&gt; 'd-m-Y',
           '#description' =&gt; date($date_format, time()),
           '#default_value' =&gt; time()
         ];


But none of them worked.
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())
    ];