Cant select time on custom form

Created on 22 June 2020, about 5 years ago
Updated 22 June 2025, 15 days ago

Hi

When I try and include the datepicker in a custom form, the time part is missing and I can only select the date. I have using the following custom code in my form:

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

    $form['dateAndTime'] = [
      '#type' => 'materialize_date_time',
      '#title' => t('Start Date'),
      '#date_format' => $date_format,
      '#default_value' => \Drupal\Core\Datetime\DrupalDateTime::createFromTimestamp(time()),
      '#weight' => '3',
    ];

Am I missing something to get it to fire the time part? If I switch back to 'datetime' the time component appears in the standard format?

Thanks

Billy

🐛 Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

🇬🇧United Kingdom billywardrop

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024