本文整理汇总了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) {
示例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');
}
示例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;
}
}
示例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));
}