function date_default_date in Date 7
Same name and namespace in other branches
- 7.3 date_api/date_api_elements.inc \date_default_date()
- 7.2 date_api/date_api_elements.inc \date_default_date()
Create a date object from a datetime string value.
4 calls to date_default_date()
- date_popup_element_value_callback in date_popup/
date_popup.module - Element value callback for date_popup element.
- date_select_element_process in date_api/
date_api_elements.inc - Flexible date/time drop-down selector.
- date_select_element_value_callback in date_api/
date_api_elements.inc - Element value callback for date_select element.
- date_text_element_value_callback in date_api/
date_api_elements.inc - Element value callback for date_text element.
File
- date_api/
date_api_elements.inc, line 124 - Date API elements themes and validation. This file is only included during the edit process to reduce memory usage.
Code
function date_default_date($element) {
$granularity = date_format_order($element['#date_format']);
$date = new DateObject($element['#default_value'], $element['#date_timezone'], DATE_FORMAT_DATETIME);
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;
}