How to display date and time picker for base field on custom entity I've made a base field on a custom entity with type "datetime" using "datetime_default" for the form display. It's displaying as only a date picker, with no time component, whereas I want it to look like this:



If I create a field in the GUI I can select between "date only" or "date and time". (The image above is the result of picking "date and time"). But I can't work out how to do this programmatically. I've tried creating fields of both types and exporting the config, but there is no difference between them, which is a mystery.

I suspect I need to put something other than "datetime_default" but I can't find any documentation on how to programmatically refer to the various date and time widgets.

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);

$fields['activity_date_time'] = BaseFieldDefinition::create('datetime')
  -&gt;setLabel(t('Date and time'))
  -&gt;setDescription('')
  -&gt;setRevisionable(TRUE)
  -&gt;setRequired(TRUE)
  -&gt;setSettings([
    'datetime_type' =&gt; 'date'
  ])  
  -&gt;setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
  -&gt;setDisplayOptions('view', [
    'label' =&gt; 'above',
    'type' =&gt; 'datetime_default',
    'settings' =&gt; [
      'format_type' =&gt; 'medium',
    ],
    'weight' =&gt; -3, 
  ])  
  -&gt;setDisplayOptions('form', [
    'type' =&gt; 'datetime_default',
    'weight' =&gt; -3, 
  ]);
setSettings(['datetime_type' =&gt; 'date']) - this seems to be to blame. See the switch in the source here which effectively says if type is 'date' (implemented as a const) then only show the date form element, otherwise show the date + time elements.