function date_iso2custom in Date 5
1 call to date_iso2custom()
- date_text_input in ./
date.inc - Text date input form, with optional jscalendar popup
File
- ./
date.inc, line 1239 - Date/time API functions
Code
function date_iso2custom($iso, $format) {
if ($iso == '') {
return NULL;
}
$array = date_iso2array($iso);
$month_short = array(
"January" => t("Jan"),
"February" => t("Feb"),
"March" => t("Mar"),
"April" => t("Apr"),
"May" => t("May"),
"June" => t("Jun"),
"July" => t("Jul"),
"August" => t("Aug"),
"September" => t("Sep"),
"October" => t("Oct"),
"November" => t("Nov"),
"December" => t("Dec"),
);
$day_short = array(
"Monday" => t("Mon"),
"Tuesday" => t("Tue"),
"Wednesday" => t("Wed"),
"Thursday" => t("Thu"),
"Friday" => t("Fri"),
"Saturday" => t("Sat"),
"Sunday" => t("Sun"),
);
$repl = array(
"d" => str_pad($array['mday'], 2, "0", STR_PAD_LEFT),
"D" => $day_short[$array['weekday']],
"j" => $array['mday'],
"l" => $array['weekday'],
"N" => '',
"S" => '',
"w" => '',
"z" => '',
"W" => '',
"F" => $array['month'],
"m" => str_pad($array['mon'], 2, "0", STR_PAD_LEFT),
"M" => $month_short[$array['month']],
"n" => $array['mon'],
"t" => '',
"L" => '',
"o" => '',
"Y" => str_pad($array['year'], 4, "0", STR_PAD_LEFT),
"y" => substr(str_pad($array['year'], 4, "0", STR_PAD_LEFT), 2, 2),
"a" => $array['hours'] >= 12 ? 'pm' : 'am',
"A" => $array['hours'] >= 12 ? 'PM' : 'AM',
"B" => '',
"g" => $array['hours'] > 12 ? $array['hours'] - 12 : $array['hours'],
"G" => $array['hours'],
"h" => str_pad($array['hours'] > 12 ? $array['hours'] - 12 : $array['hours'], 2, "0", STR_PAD_LEFT),
"H" => str_pad($array['hours'], 2, "0", STR_PAD_LEFT),
"i" => str_pad($array['minutes'], 2, "0", STR_PAD_LEFT),
"s" => str_pad($array['seconds'], 2, "0", STR_PAD_LEFT),
"e" => '',
"I" => '',
"O" => '',
"P" => '',
"T" => '',
"z" => '',
"c" => '',
"r" => '',
"U" => '',
);
$repl["\\\\"] = "\\";
foreach ($repl as $key => $value) {
$repl["\\" . $key] = $key;
}
return strtr($format, $repl);
}