X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fdatetime.php;h=efcfa0a177eb8319e8feb6cd64033962efea333d;hb=5e3076b5d27f393f1f7c8d97cf5841064bce88e0;hp=e3e9b9dbf6dd8ab286008ca55a66070925f61c27;hpb=78ede4744ff17c564f7104731c152672138f3efb;p=friendica.git diff --git a/include/datetime.php b/include/datetime.php index e3e9b9dbf6..efcfa0a177 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -100,11 +100,33 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d return str_replace('1','0',$d->format($fmt)); } - $d = new DateTime($s, new DateTimeZone($from)); - $d->setTimeZone(new DateTimeZone($to)); + try { + $from_obj = new DateTimeZone($from); + } + catch(Exception $e) { + $from_obj = new DateTimeZone('UTC'); + } + + try { + $d = new DateTime($s, $from_obj); + } + catch(Exception $e) { + logger('datetime_convert: exception: ' . $e->getMessage()); + $d = new DateTime('now', $from_obj); + } + + try { + $to_obj = new DateTimeZone($to); + } + catch(Exception $e) { + $to_obj = new DateTimeZone('UTC'); + } + + $d->setTimeZone($to_obj); return($d->format($fmt)); }} + // wrapper for date selector, tailored for use in birthday fields function dob($dob) { @@ -448,7 +470,7 @@ function update_contact_birthdays() { */ $bdtext = sprintf( t('%s\'s birthday'), $rr['name']); - $bdtext2 = sprintf( t('Happy Birthday %s'), ' [url=' . $rr['url'] . ']' . $rr['name'] . '[/url]' ; + $bdtext2 = sprintf( t('Happy Birthday %s'), ' [url=' . $rr['url'] . ']' . $rr['name'] . '[/url]') ;