I wrote the following functions (if anyone else out there is interested).
function FormatDate($str) {
$now = DateDecode(date( 'Y-m-d H:i:s'), "mysql");
if ($str['day'] == $now['day'] && $str['month'] == $now['month'] && $str['year'] == $now['year']) {
return "Today at " . $str['hour'] . ":" . $str['minute'] . "" . $str['postfix'];
}
$xs = strtotime($str['year'] . "-" . $str['month'] . "-" . $str['day'] . " " . $str['hour'] . ":" . $str['minute'] . ":" . $str['seccond']);
if (strftime("%U", $xs) == strftime("%U")) {
return strftime("%A", $xs) .
" at " . $str['hour'] . ":" . $str['minute'] . "" . $str['postfix'];
}
else {
return strftime("%A", $xs) . " " . $str['day'] . "/" . $str['month'] . " at " . $str['hour'] . ":" . $str['minute'] . "" . $str['postfix'];
}
}
function DateDecode($str, $format) {
if ($format == "mysql") {
$date['postfix'] = 'AM';
$date['year'] = substr($str, 0, 4);
$date['month'] = substr($str, 5, 2);
$date['day'] = substr($str, 8, 2);
$date['hour'] = substr($str, 11, 2);
if ($date['hour'] > 12) {
$date['hour'] = $date['hour'] - 12;
$date['postfix'] = 'PM';
}
$date['minute'] = substr($str, 14, 2);
$date['seccond'] = substr($str, 17, 2);
return $date;
}
}