Handle DateTime exceptions

pull/1/head
thomascube 13 years ago
parent ac78df3417
commit 87986cfdb9

@ -1062,15 +1062,25 @@ function format_date($date, $format=NULL, $convert=true)
if (empty($ts))
return '';
try {
$date = new DateTime("@".$ts);
}
catch (Exception $e) {
return 'unknown';
}
try {
// convert to the right timezone
$stz = date_default_timezone_get();
$tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezone') : 'GMT');
date_default_timezone_set($tz->getName());
$tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezones') : 'GMT');
$date->setTimezone($tz);
date_default_timezone_set($tz->getName());
$timestamp = $date->format('U');
}
catch (Exception $e) {
$timestamp = $ts;
}
// define date format depending on current time
if (!$format) {

Loading…
Cancel
Save