public static Datetime::validateDatetime(&$element, FormStateInterface $form_state, &$complete_form)
Validation callback for a datetime element.
If the date is valid, the date object created from the user input is set in the form for use by the caller. The work of compiling the user input back into a date object is handled by the value callback, so we can use it here. We also have the raw input available for validation testing.
Parameters
array $element: The form element whose value is