function date_iso2unix in Date 5
8 calls to date_iso2unix()
- date_custom2unix in ./
date.inc - date_iso2array in ./
date.inc - date_iso_week_range in ./
date.inc - Compute min and max dates for an ISO week
- date_set_date in ./
date.inc - Function to set local and db date parts in the date object
- date_text2unix in ./
date.inc
File
- ./
date.inc, line 1213 - Date/time API functions
Code
function date_iso2unix($iso) {
if (!date_preg($iso)) {
return 'ERROR';
}
if (!date_is_valid($iso, DATE_ISO)) {
return 'ERROR';
}
// A unix date requires a year, month, and day.
// Make sure not to set '0' for month or day since that will revert to
// the previous month or day.
if (date_iso_year($iso)) {
$array = array(
'hours' => date_iso_hours($iso),
'minutes' => date_iso_minutes($iso),
'seconds' => date_iso_seconds($iso),
'mon' => max(1, date_iso_mon($iso)),
'mday' => max(1, date_iso_day($iso)),
'year' => date_iso_year($iso),
);
// using gmmktime instead of mktime so no server timezone adjustment is made
$unix = date_gmmktime($array);
// php versions earlier than 5.1 return -1 for a false response, convert that to 'ERROR'
if ($unix == -1) {
return 'ERROR';
}
return $unix;
}
else {
return NULL;
}
}