function webform_date_string in Webform 6.3
Same name and namespace in other branches
- 7.4 webform.module \webform_date_string()
- 7.3 webform.module \webform_date_string()
Convert an array of a date or time into an ISO 8601 compatible string.
Parameters
$array: The array to convert to a date or time string.
$type: If wanting a specific string format back specify either "date" or "time". Otherwise a full ISO 8601 date and time string will be returned.
4 calls to webform_date_string()
- webform_expand_time in components/
time.inc - Form API #process function for Webform time fields.
- webform_update_6314 in ./
webform.install - Convert Dates and Times into using ISO 8601 strings instead of 3 rows.
- _webform_submit_date in components/
date.inc - Implements _webform_submit_component().
- _webform_submit_time in components/
time.inc - Implements _webform_submit_component().
File
- ./
webform.module, line 3507
Code
function webform_date_string($array, $type = NULL) {
$string = '';
if ($type == 'date' || !isset($type)) {
$string .= empty($array['year']) ? '0000' : sprintf('%04d', $array['year']);
$string .= '-';
$string .= empty($array['month']) ? '00' : sprintf('%02d', $array['month']);
$string .= '-';
$string .= empty($array['day']) ? '00' : sprintf('%02d', $array['day']);
}
if (!isset($type)) {
$string .= 'T';
}
if ($type == 'time' || !isset($type)) {
$string .= empty($array['hour']) ? '00' : sprintf('%02d', $array['hour']);
$string .= ':';
$string .= empty($array['minute']) ? '00' : sprintf('%02d', $array['minute']);
$string .= ':';
$string .= empty($array['second']) ? '00' : sprintf('%02d', $array['second']);
}
return $string;
}