Exemplo n.º 1
0
 /**
  * Sets the default time zone.
  *
  * @param string $timeZoneString String time zone (eg, Europe/London);
  */
 public static function setDefaultTimeZone($timeZoneString)
 {
     self::$_timeZone = new DateTimeZone($timeZoneString);
     if (method_exists('DateTime', 'setTimestamp')) {
         self::$_dateObj = new DateTime('', self::$_timeZone);
     }
 }
Exemplo n.º 2
0
 /**
  * Sets the default time zone.
  *
  * @param string|DateTimeZone $timeZoneString String time zone (eg, Europe/London);
  */
 public static function setDefaultTimeZone($timeZoneString)
 {
     if (!$timeZoneString) {
         return;
     }
     if ($timeZoneString instanceof DateTimeZone) {
         self::$_timeZone = $timeZoneString;
     } else {
         try {
             self::$_timeZone = new DateTimeZone($timeZoneString);
         } catch (Exception $e) {
             return;
         }
     }
     if (method_exists('DateTime', 'setTimestamp')) {
         self::$_dateObj = new DateTime('', self::$_timeZone);
     }
 }