diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index 51e74f8..b23d7d2 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -1139,8 +1139,11 @@ function datetime_range_years($string, $date = NULL) { function datetime_form_node_form_alter(&$form, &$form_state, $form_id) { // Alter the 'Authored on' date to use datetime. $form['author']['date']['#type'] = 'datetime'; - $form['author']['date']['#description'] = t('Format: %format. Leave blank to use the time of form submission.', array('%format' => datetime_format_example($date_format))); + $form['author']['date'] += element_info('datetime'); unset($form['author']['date']['#maxlength']); + + $format = trim(datetime_html5_format('date', $form['author']['date']) . ' ' . datetime_html5_format('time', $form['author']['date'])); + $form['author']['date']['#description'] = t('Format: %format. Leave blank to use the time of form submission.', array('%format' => datetime_format_example($format))); } /** diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index 6fa84ef..98a827f 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -44,8 +44,8 @@ protected function prepareEntity() { else { $config = \Drupal::config('system.date'); $format_type = datetime_default_format_type(); - $date_format = $config->get('formats.html_date.pattern.' . $format_type) . ' ' . $config->get('formats.html_time.pattern.' . $format_type); - $node->date = format_date($node->created, 'custom', $date_format); + $format = $config->get('formats.html_date.pattern.' . $format_type) . ' ' . $config->get('formats.html_time.pattern.' . $format_type); + $node->date = format_date($node->created, 'custom', $format); // Remove the log message from the original node entity. $node->log = NULL; } @@ -193,12 +193,12 @@ public function form(array $form, array &$form_state) { ); $config = \Drupal::config('system.date'); $format_type = datetime_default_format_type(); - $date_format = $config->get('formats.html_date.pattern.' . $format_type) . ' ' . $config->get('formats.html_time.pattern.' . $format_type); + $format = $config->get('formats.html_date.pattern.' . $format_type) . ' ' . $config->get('formats.html_time.pattern.' . $format_type); $form['author']['date'] = array( '#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, - '#description' => t('Format: %format. Leave blank to use the time of form submission.', array('%format' => $date_format)), + '#description' => t('Format: %format. Leave blank to use the time of form submission.', array('%format' => $format)), '#default_value' => !empty($node->date) ? $node->date : '', );