Implements hook_form_BASE_FORM_ID_alter() for node forms.
function datetime_form_node_form_alter(&$form, &$form_state, $form_id) {
// Alter the 'Authored on' date to use datetime.
$form['author']['date']['#type'] = 'datetime';
$config = Drupal::config('system.date');
$format = $config
->get('formats.html_date') . ' ' . $config
->get('formats.html_time');
$form['author']['date']['#description'] = t('Format: %format. Leave blank to use the time of form submission.', array(
'%format' => datetime_format_example($format),
));
unset($form['author']['date']['#maxlength']);
}