示例#1
0
 /**
  * Convert given date string with UTC timezone into default locale format
  * and locale timezone
  *
  * @param string $date date string in SQL format with UTC timezone
  * @return Zend_Date
  */
 public static function getDateFromDb($date)
 {
     if (!is_string($date)) {
         throw new Zmz_Date_Exception('$date must be a string');
     }
     $tmpDate = new Zend_Date();
     $tmpDate->setTimezone('UTC');
     $tmpDate->set($date, self::SQL_DATETIME);
     $tmpDate->setTimezone(Zmz_Culture::getTimezone());
     return $tmpDate;
 }
示例#2
0
 /**
  * Convert given date string with UTC timezone into default locale format
  * and locale timezone
  *
  * @param string $date date string in SQL format with UTC timezone
  * @param string $defaultDate date to use if $date is null
  * @return Zend_Date
  */
 public static function getDateFromDb($date, $defaultDate = null)
 {
     if ($defaultDate == null) {
         $defaultDate = "1970-01-01 00:00:00";
     }
     if (null === $date) {
         $date = $defaultDate;
     }
     if (!is_string($date)) {
         throw new Exception('$date must be a string');
     }
     $tmpDate = new Zend_Date();
     $tmpDate->setTimezone('UTC');
     $tmpDate->set($date, self::SQL_DATETIME);
     $tmpDate->setTimezone(Zmz_Culture::getTimezone());
     return $tmpDate;
 }