當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Date::subYear方法代碼示例

本文整理匯總了PHP中Zend_Date::subYear方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Date::subYear方法的具體用法?PHP Zend_Date::subYear怎麽用?PHP Zend_Date::subYear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Date的用法示例。


在下文中一共展示了Zend_Date::subYear方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: aggregate

 public function aggregate($from = null)
 {
     if (!is_null($from)) {
         $from = $this->formatDate($from);
     }
     if ($from == null) {
         $from = new Zend_Date(Mage::getSingleton('core/date')->gmtTimestamp(), null, Mage::app()->getLocale()->getLocaleCode());
         $from->subYear(10);
         $this->_aggregateTickets($from->get(Varien_Date::DATETIME_INTERNAL_FORMAT));
     } else {
         $this->_aggregateTickets($from);
     }
     $this->_refreshFlag();
     return $this;
 }
開發者ID:cesarfelip3,項目名稱:clevermage_new,代碼行數:15,代碼來源:Mirasvit_Helpdesk_Model_Resource_Report_Ticket.php

示例2: testLoose


//.........這裏部分代碼省略.........
         // success
     }
     try {
         $date->addArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:67,代碼來源:DateTest.php

示例3: getPredefinedRange

 /**
  * 取得某個預定義時間段
  * 
  * @static
  * @param integer $interval
  * @param string $forceUnit
  * @param integer $timestamp
  * @return array
  */
 public static function getPredefinedRange($interval, $forceUnit = null, $timestamp = null)
 {
     if (empty($timestamp)) {
         $timestamp = time();
     }
     $start = new Zend_Date($timestamp);
     $end = new Zend_Date($timestamp);
     switch ($interval) {
         case self::TODAY:
             $start->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::HOUR;
             break;
         case self::YESTODAY:
             $start->subDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::TOMORROW:
             $start->addDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::THIS_MONTH:
             $start->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_YEAR:
             $start->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end->addMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_SEASON:
             $start->setMonth(3 * floor(($start->toValue('M') - 1) / 3) + 1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
         case self::RECENT_24HOUR:
             $start->subHour(24);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_48HOUR:
             $start->subHour(48);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_1WEEK:
             $start->subWeek(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_1MONTH:
             $start->subMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_24MONTH:
             $start->subMonth(24);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1MONTH:
             $start->subMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1YEAR:
             $start->subYear(1)->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addYear(1);
             $unit = Zend_Date::DAY;
             break;
         case self::ENTIRE_DAY:
             $start->setDate(self::ERA_DATE, self::ZF_DATE_FORMAT)->setTime(self::ERA_TIME, self::ZF_TIME_FORMAT);
             $end->addDay(1);
             $unit = Zend_Date::DAY;
             break;
         default:
             $unit = Zend_Date::SECOND;
     }
     if (!empty($forceUnit)) {
         $unit = $forceUnit;
     }
     $start = max(self::truncateDatetime($start, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     $end = max(self::truncateDatetime($end, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     return compact('start', 'end', 'unit');
 }
開發者ID:starflash,項目名稱:ZtChart-ZF1-Example,代碼行數:92,代碼來源:Datetime.php

示例4: getAge

 public function getAge($atDate = null)
 {
     if ($atDate) {
         $zd = new Zend_Date($atDate);
     } else {
         $zd = new Zend_Date(Zend_Date::now());
     }
     if ($this->getBirthdate()) {
         $from = new Zend_Date($this->getBirthdate());
         return $zd->subYear($from)->get(zend_Date::YEAR);
     } else {
         return -1;
     }
 }
開發者ID:brunopbaffonso,項目名稱:ongonline,代碼行數:14,代碼來源:Person.php

示例5: getInterval

 /**
  * Return interval (two GMT Zend_Date).
  *
  * @param $code
  * @param bool $timezone
  *
  * @return Varien_Object
  */
 public function getInterval($code, $timezone = false)
 {
     $timestamp = Mage::getSingleton('core/date')->gmtTimestamp();
     if ($timezone) {
         $timestamp = Mage::app()->getLocale()->date($timestamp);
     }
     $from = new Zend_Date($timestamp, null, Mage::app()->getLocale()->getLocaleCode());
     $to = clone $from;
     $dateInterval = null;
     switch ($code) {
         case self::TODAY:
             $from->setTime('00:00:00');
             $to->setTime('23:59:59');
             break;
         case self::YESTERDAY:
             $from->subDay(1)->setTime('00:00:00');
             $to->subDay(1)->setTime('23:59:59');
             break;
         case self::THIS_MONTH:
             $from->setDay(1)->setTime('00:00:00');
             $to->setDay(1)->addDay($to->get(Zend_Date::MONTH_DAYS) - 1)->setTime('23:59:59');
             break;
         case self::PREVIOUS_MONTH:
             $from->setDay(1)->subMonth(1)->setTime('00:00:00');
             $to->setDay(1)->setTime('23:59:59')->subMonth(1)->addDay($to->get(Zend_Date::MONTH_DAYS) - 1);
             break;
         case self::THIS_QUARTER:
             $month = intval($from->get(Zend_Date::MONTH) / 4) * 3 + 1;
             $from->setDay(1)->setMonth($month)->setTime('00:00:00');
             $to->setDay(1)->setMonth($month)->addMonth(3)->subDay(1)->setTime('23:59:59');
             break;
         case self::PREVIOUS_QUARTER:
             $month = intval($from->get(Zend_Date::MONTH) / 4) * 3 + 1;
             $from->setDay(1)->setMonth($month)->setTime('00:00:00')->subMonth(3);
             $to->setDay(1)->setMonth($month)->addMonth(3)->subDay(1)->setTime('23:59:59')->subMonth(3);
             break;
         case self::THIS_YEAR:
             $from->setDay(1)->setMonth(1)->setTime('00:00:00');
             $to->setDay(1)->setMonth(1)->addDay($to->get(Zend_Date::LEAPYEAR) ? 365 : 364)->setTime('23:59:59');
             break;
         case self::PREVIOUS_YEAR:
             $from->setDay(1)->setMonth(1)->setTime('00:00:00')->subYear(1);
             $to->setDay(1)->setMonth(1)->addDay($to->get(Zend_Date::LEAPYEAR) ? 365 : 364)->setTime('23:59:59')->subYear(1);
             break;
         case self::LAST_24H:
             $from->subDay(1);
             break;
         case self::THIS_WEEK:
             $weekday = $from->get(Zend_Date::WEEKDAY_DIGIT);
             #0-6
             $from->setTime('00:00:00')->subDay($weekday);
             $to->setTime('23:59:59')->addDay(6 - $weekday);
             break;
         case self::PREVIOUS_WEEK:
             $weekday = $from->get(Zend_Date::WEEKDAY_DIGIT);
             #0-6
             $from->setTime('00:00:00')->subDay($weekday)->subWeek(1);
             $to->setTime('23:59:59')->addDay(6 - $weekday)->subWeek(1);
             break;
         case self::LAST_7D:
             $from->subDay(7);
             break;
         case self::LAST_30D:
             $from->subDay(30);
             break;
         case self::LAST_3M:
             $from->subMonth(3);
             break;
         case self::LAST_12M:
             $from->subYear(1);
             break;
         case self::LIFETIME:
             $from->subYear(10);
             $to->addYear(10);
             break;
     }
     return new Varien_Object(array('from' => $from, 'to' => $to));
 }
開發者ID:cesarfelip3,項目名稱:clevermage_new,代碼行數:86,代碼來源:Report.php


注:本文中的Zend_Date::subYear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。