summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/main.inc24
1 files changed, 17 insertions, 7 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 66de2e5d8..b0736625a 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1062,15 +1062,25 @@ function format_date($date, $format=NULL, $convert=true)
if (empty($ts))
return '';
- $date = new DateTime("@".$ts);
+ try {
+ $date = new DateTime("@".$ts);
+ }
+ catch (Exception $e) {
+ return 'unknown';
+ }
- // 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());
- $date->setTimezone($tz);
+ try {
+ // convert to the right timezone
+ $stz = date_default_timezone_get();
+ $tz = new DateTimeZone($convert ? $RCMAIL->config->get('timezones') : 'GMT');
+ $date->setTimezone($tz);
+ date_default_timezone_set($tz->getName());
- $timestamp = $date->format('U');
+ $timestamp = $date->format('U');
+ }
+ catch (Exception $e) {
+ $timestamp = $ts;
+ }
// define date format depending on current time
if (!$format) {