本文整理汇总了PHP中Zend_Date::subWeek方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::subWeek方法的具体用法?PHP Zend_Date::subWeek怎么用?PHP Zend_Date::subWeek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::subWeek方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoose
//.........这里部分代码省略.........
// success
}
try {
$date->addDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareDay(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
示例2: _processFilter
/**
* @param $filter
*
* @return mixed
*/
protected function _processFilter($filter)
{
$period = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS;
if (array_key_exists('period', $filter)) {
$period = intval($filter['period']);
}
$filter['period'] = $period;
$fromDate = new Zend_Date();
$toDate = new Zend_Date();
$fromDate->setHour(23)->setMinute(59)->setSecond(59);
$toDate->setHour(23)->setMinute(59)->setSecond(59);
switch ($period) {
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_TODAY:
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_YESTERDAY:
$fromDate->subDay(1);
$toDate->subDay(1);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_WEEK:
$firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
if ($firstDayOfWeek === 0) {
$firstDayOfWeek = 7;
}
$fromDate->setWeekday($firstDayOfWeek);
if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
$fromDate->subWeek(1);
}
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_WEEK:
$fromDate->subWeek(1);
$toDate->subWeek(1);
$firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
if ($firstDayOfWeek === 0) {
$firstDayOfWeek = 7;
}
$fromDate->setWeekday($firstDayOfWeek);
if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
$fromDate->subWeek(1);
}
$lastDayOfWeek = $firstDayOfWeek - 1;
if ($lastDayOfWeek < 1) {
$lastDayOfWeek = 7;
}
$toDate->setWeekday($lastDayOfWeek);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_MONTH:
$fromDate->setDay(1);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_MONTH:
$fromDate->subMonth(1)->setDay(1);
$toDate->setDay(1)->subDay(1);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SIX_MONTHS:
$fromDate->subMonth(6);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_CUSTOM:
$_reversed = false;
$_now = new Zend_Date(null, 'dd/MM/y');
try {
$_fromDate = new Zend_Date($filter['from_date'], 'dd/MM/y');
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "From" date value'));
$_fromDate = clone $_now;
}
try {
$_toDate = new Zend_Date($filter['to_date'], 'dd/MM/y');
if ($_fromDate->compare($_toDate) > 0) {
$_reversed = true;
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "To" date value'));
$_toDate = clone $_now;
}
if ($_reversed) {
$fromDate = $_toDate;
$toDate = $_fromDate;
} else {
$fromDate = $_fromDate;
$toDate = $_toDate;
}
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SEVEN_DAYS:
$fromDate->subDay(6);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS:
$fromDate->subDay(29);
break;
}
$filter['from_date'] = $fromDate;
$filter['to_date'] = $toDate;
if (!array_key_exists('group', $filter)) {
$filter['group'] = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::GROUP_BY_WEEK;
}
if (!array_key_exists('agents[]', $filter)) {
$filter['agents[]'] = $this->_getAgentIds();
//.........这里部分代码省略.........
示例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');
}