I am storing dates in a MySQL database in datetime fields in UTC. I\'m using PHP, and I\'ve called date_timezone_set(\'UTC\') so that all calls to date() (without timestamp)
setTimezone(new DateTimeZone(trim($to_dtz)));
$time_now_object->setTimezone(new DateTimeZone(trim($to_dtz)));
// Is day = day in $time_now_object, $time_object..?
if ($time_now_object->format('d') == $time_object->format('d')) {
return $time_object->format('H:i:s');
} else {
return $time_object->format('Y-m-d H:i:s');
}
} else {
return '';
}
}
?>
Use sample: