function date_text_input_value in Date 6
Same name and namespace in other branches
- 5.2 date_api_elements.inc \date_text_input_value()
- 6.2 date_api_elements.inc \date_text_input_value()
Helper function for extracting a date value out of user input.
1 call to date_text_input_value()
- date_text_validate in ./
date_api_elements.inc - Validation for text input.
File
- ./
date_api_elements.inc, line 445 - Date API elements themes and validation. This file is only included during the edit process to reduce memory usage.
Code
function date_text_input_value($element) {
$form_values = $element['#value'];
$input = $form_values['date'];
if (!$element['#required'] && trim($input) == '') {
return NULL;
}
$value = date_convert_from_custom($input, $element['#date_format']);
// If it creates a valid date, use it.
if (date_is_valid($value)) {
return $value;
}
else {
$date = strtotime($input, 0);
if (date_is_valid($date, DATE_UNIX)) {
return date_convert($date, DATE_UNIX, DATE_DATETIME);
}
}
return NULL;
}