1 date.elements.inc date_text_input_date($element, $input)

Helper function for creating a date object out of user input.

File

core/modules/date/date.elements.inc, line 457
Date forms and form themes and validation.

Code

function date_text_input_date($element, $input) {
  if (empty($input) || !is_array($input) || !array_key_exists('date', $input) || empty($input['date'])) {
    return NULL;
  }
  $granularity = date_format_order($element['#date_format']);

  $date = new BackdropDateTime($input['date'], $element['#date_timezone'], $element['#date_format']);

  if (is_object($date)) {
    $date->limitGranularity($granularity);
    if ($date->validGranularity($granularity, $element['#date_flexible'])) {
      date_increment_round($date, $element['#date_increment']);
    }
    return $date;
  }
  return NULL;
}