/** * Construct * * @param string $date Date * @param mixed $tz Timezone */ public function __construct($date = 'now', $tz = null) { $app = JFactory::getApplication(); $orig = $date; $date = $this->stripDays($date); /* not sure if this one needed? * $date = $this->monthToInt($date); */ $date = $this->removeDashes($date); try { $dt = new DateTime($date); } catch (Exception $e) { JDEBUG ? $app->enqueueMessage('date format unknown for ' . $orig . ' replacing with today\'s date', 'notice') : ''; $date = 'now'; /* catches 'Failed to parse time string (ublingah!) at position 0 (u)' exception. * don't use this object */ } // Create the base GMT and server time zone objects. if (empty(self::$gmt) || empty(self::$stz)) { self::$gmt = new DateTimeZone('GMT'); self::$stz = new DateTimeZone(@date_default_timezone_get()); } parent::__construct($date, $tz); }
public function __construct($date = 'now', $tz = null) { $orig = $date; $date = $this->stripDays($date); //not sure if this one needed? // $date = $this->monthToInt($date); $date = $this->removeDashes($date); try { $dt = new DateTime($date); } catch (Exception $e) { JError::raiseNotice(500, 'date format unknown for ' . $orig . ' replacing with todays date'); $date = 'now'; // catches 'Failed to parse time string (ublingah!) at position 0 (u)' exception. // don't use this object } // Create the base GMT and server time zone objects. if (empty(self::$gmt) || empty(self::$stz)) { self::$gmt = new DateTimeZone('GMT'); self::$stz = new DateTimeZone(@date_default_timezone_get()); } parent::__construct($date, $tz); }