当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Date::addWeek方法代码示例

本文整理汇总了PHP中Zend_Date::addWeek方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::addWeek方法的具体用法?PHP Zend_Date::addWeek怎么用?PHP Zend_Date::addWeek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Date的用法示例。


在下文中一共展示了Zend_Date::addWeek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save(Default_Model_Pastebin $pastebin)
 {
     $shortId = $pastebin->getShortId();
     if (empty($shortId)) {
         $shortId = $this->_getShortId();
         $pastebin->setShortId($shortId);
     }
     $name = $pastebin->getName();
     $expiresTime = $pastebin->getExpires();
     $expires = null;
     if ($expiresTime != 'never') {
         $expires = new Zend_Date();
         if ($expiresTime == 'hour') {
             $expires->addHour(1);
         }
         if ($expiresTime == 'day') {
             $expires->addDay(1);
         }
         if ($expiresTime == 'week') {
             $expires->addWeek(1);
         }
         if ($expiresTime == 'month') {
             $expires->addMonth(1);
         }
         $expires = $expires->get('yyyy-MM-dd HH:mm:ss');
     }
     $data = array('short_id' => $shortId, 'name' => !empty($name) ? $name : 'Anonymous', 'code' => $pastebin->getCode(), 'language' => $pastebin->getLanguage(), 'expires' => $expires, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'created' => date('Y-m-d H:i:s'));
     if (null === ($id = $pastebin->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
     return $shortId;
 }
开发者ID:sebflipper,项目名称:zf-pastebin,代码行数:35,代码来源:PastebinMapper.php

示例2: testLoose


//.........这里部分代码省略.........
         // success
     }
     try {
         $date->setDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // 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) {
开发者ID:jsnshrmn,项目名称:Suma,代码行数:67,代码来源:DateTest.php

示例3: getIntervals

 /**
  * Overrides standard getIntervals
  * @return array
  */
 public function getIntervals()
 {
     if (!$this->_intervals) {
         $this->_intervals = array();
         if (!$this->_from && !$this->_to) {
             return $this->_intervals;
         }
         $dateStart = new Zend_Date($this->_from);
         $dateStart2 = new Zend_Date($this->_from);
         $dateEnd = new Zend_Date($this->_to);
         $t = array();
         while ($dateStart->compare($dateEnd) <= 0) {
             switch ($this->_period) {
                 case 'day':
                     $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                     $t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
                     $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
                     $dateStart->addDay(1);
                     break;
                 case 'week':
                     $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                     $t['start'] = $dateStart->toString('yyyy-MM-dd 00:00:00');
                     $dateStart->addWeek(1)->subDay(1);
                     $t['title'] .= ' - ' . $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                     $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
                     $dateStart->addDay(1);
                     break;
                 case 'month':
                     $t['title'] = $dateStart->toString('MM/yyyy');
                     $t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
                     $t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                     $dateStart->addMonth(1);
                     break;
                 case 'quarter':
                     $month = (int) $dateStart->toString('MM');
                     $num = round($month / 3) + 1;
                     $t['title'] = Mage::helper('advancedreports')->__('Q') . $num . $dateStart->toString('/yyyy');
                     $t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
                     $dateStart->addMonth(2);
                     $t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                     $dateStart->addMonth(1);
                     break;
                 case 'year':
                     $t['title'] = $dateStart->toString('yyyy');
                     $t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
                     $t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
                     $dateStart->addYear(1);
                     break;
             }
             $this->_intervals[$t['title']] = $t;
             //		echo $t['start'].' - '.$t['end'].'<hr>';
         }
         if ($this->_period != 'day') {
             $titles = array_keys($this->_intervals);
             if (count($titles) > 0) {
                 $this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
                 $this->_intervals[$titles[count($titles) - 1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
                 if ($this->_period == 'week') {
                     $t = $this->_intervals[$titles[count($titles) - 1]];
                     unset($this->_intervals[$titles[count($titles) - 1]]);
                     $date = new Zend_Date($t['start']);
                     $t['title'] = $date->toString(Mage::app()->getLocale()->getDateFormat());
                     unset($date);
                     $date = new Zend_Date($t['end']);
                     $t['title'] .= ' - ' . $date->toString(Mage::app()->getLocale()->getDateFormat());
                     $this->_intervals[$t['title']] = $t;
                 }
             }
         }
     }
     return $this->_intervals;
 }
开发者ID:xiaoguizhidao,项目名称:autotech_design,代码行数:76,代码来源:Collection.php

示例4: getIntervals

 /**
  * Overrides standard getIntervals
  * @return array
  */
 public function getIntervals()
 {
     if (!$this->_intervals) {
         $this->_intervals = array();
         if (!$this->_from && !$this->_to) {
             return $this->_intervals;
         }
         $t = array();
         $diff = 0;
         if ($this->_period == 'week') {
             $firstWeekDay = Mage::getStoreConfig('general/locale/firstday');
             $dateStart = new Zend_Date($this->_from);
             $curWeekDay = $dateStart->toString('e');
             if ($curWeekDay > $firstWeekDay) {
                 $firstWeekDay += 7;
             }
             $diff = abs($curWeekDay - $firstWeekDay);
         }
         if ($this->_period == 'week' && $diff > 0) {
             $dateStart = new Zend_Date($this->_from);
             $dateStart2 = new Zend_Date($this->_from);
             $dateStart2->addDay($diff);
             $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
             $t['start'] = $dateStart->toString('yyyy-MM-dd 00:00:00');
             $dateStart->addDay($diff)->subDay(1);
             $t['title'] .= ' - ' . $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
             $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
             $dateStart->addDay(1);
             if (isset($t['title'])) {
                 $this->_intervals[$t['title']] = $t;
             }
             $dateStart2 = new Zend_Date($this->_from);
             $dateEnd = new Zend_Date($this->_to);
         } else {
             $dateStart = new Zend_Date($this->_from);
             $dateStart2 = new Zend_Date($this->_from);
             $dateEnd = new Zend_Date($this->_to);
         }
         while ($dateStart->compare($dateEnd) <= 0) {
             switch ($this->_period) {
                 case 'day':
                     $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                     $t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
                     $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
                     $dateStart->addDay(1);
                     break;
                 case 'week':
                     $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                     $t['start'] = $dateStart->toString('yyyy-MM-dd 00:00:00');
                     $dateStart->addWeek(1)->subDay(1);
                     $t['title'] .= ' - ' . $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                     $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
                     $dateStart->addDay(1);
                     break;
                 case 'month':
                     $t['title'] = $dateStart->toString('MM/yyyy');
                     $t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
                     $t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                     $dateStart->addMonth(1);
                     break;
                 case 'quarter':
                     $month = (int) $dateStart->toString('MM');
                     $num = round($month / 3) + 1;
                     $t['title'] = Mage::helper('advancedreports')->__('Q') . $num . $dateStart->toString('/yyyy');
                     $t['start'] = $dateStart->toString('yyyy-MM-01 00:00:00');
                     $dateStart->addMonth(2);
                     $t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                     $dateStart->addMonth(1);
                     break;
                 case 'year':
                     $t['title'] = $dateStart->toString('yyyy');
                     $t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
                     $t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
                     $dateStart->addYear(1);
                     break;
                 default:
                     Mage::throwException("Report tried to get intervals without a period.");
             }
             if (isset($t['title'])) {
                 $this->_intervals[$t['title']] = $t;
             }
             //                echo $t['start'].' - '.$t['end'].'<hr>';
         }
         if ($this->_period != 'day') {
             $titles = array_keys($this->_intervals);
             if (count($titles) > 0) {
                 $this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
                 $this->_intervals[$titles[count($titles) - 1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
                 if ($this->_period == 'week') {
                     $t = $this->_intervals[$titles[count($titles) - 1]];
                     unset($this->_intervals[$titles[count($titles) - 1]]);
                     $date = new Zend_Date($t['start'], 'yyyy-MM-dd 00:00:00');
                     $t['title'] = $date->toString(Mage::app()->getLocale()->getDateFormat());
                     unset($date);
                     $date = new Zend_Date($t['end'], 'yyyy-MM-dd 23:59:59');
                     $t['title'] .= ' - ' . $date->toString(Mage::app()->getLocale()->getDateFormat());
//.........这里部分代码省略.........
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:101,代码来源:Collection.php

示例5: getGroupedByPeriod

 /**
  * @param array $statistics (array('2014-01-01' => 2,'2014-01-02' => 0))
  * @param int $periodType
  *
  * @return array (array('2014-01' => 2))
  */
 public function getGroupedByPeriod($statistics, $periodType)
 {
     if ($periodType == self::PERIOD_DAY_TYPE) {
         return $statistics;
     }
     ksort($statistics);
     //get first key
     $intervalDate = new Zend_Date(key($statistics), Varien_Date::DATE_INTERNAL_FORMAT);
     //reset day to 1
     $intervalDate->setDay(1);
     if ($periodType == self::PERIOD_WEEK_TYPE) {
         //for week period need set start interval like 2014-01-07
         $firstWeekDay = (int) Mage::getStoreConfig('general/locale/firstday') == 0 ? 7 : (int) Mage::getStoreConfig('general/locale/firstday');
         $intervalDate->setWeekday($firstWeekDay);
         if ($intervalDate->toString(Varien_Date::DATE_INTERNAL_FORMAT) == key($statistics)) {
             $intervalDate->addWeek(1);
         }
         $intervalDate->subDay(1);
     }
     $result = array();
     foreach ($statistics as $key => $value) {
         if (!$this->_isInPeriodInterval($intervalDate, $key, $periodType)) {
             $this->_setPeriodIntervalIndex($intervalDate, $key, $periodType);
         }
         $intervalIndex = $intervalDate->toString($this->_getPeriodIntervalDateFormat($periodType));
         if ($periodType == self::PERIOD_WEEK_TYPE) {
             $_prevWeek = clone $intervalDate;
             $_prevWeek->subWeek(1);
             $_prevWeek->addDay(1);
             $_prevWeekIndex = $_prevWeek->toString($this->_getPeriodIntervalDateFormat($periodType));
             $result[$_prevWeekIndex . '/' . $intervalIndex] = (array_key_exists($_prevWeekIndex . '/' . $intervalIndex, $result) ? $result[$_prevWeekIndex . '/' . $intervalIndex] : 0) + $this->_getValue($value);
         } else {
             $result[$intervalIndex] = (array_key_exists($intervalIndex, $result) ? $result[$intervalIndex] : 0) + $this->_getValue($value);
         }
     }
     return $result;
 }
开发者ID:protechhelp,项目名称:gamamba,代码行数:43,代码来源:Statistics.php

示例6: _save

 /**
  * Save question data
  * @param array|Wenda_Model_DbTable_QuestionTable $data
  * @return boolean
  */
 protected function _save($data)
 {
     $auth = RFLib_Core::getService('authentication')->getAuth();
     if (!$auth->hasIdentity()) {
         return false;
     }
     $user = $auth->getStorage()->read();
     $date = new Zend_Date();
     if (isset($data['id'])) {
         $row = $this->getTable('Question')->findById($data['id']);
     } else {
         $row = null;
     }
     if (null === $row) {
         $data['user_id'] = $user['id'];
         $data['created_at'] = $date->getTimestamp();
         $data['expired_at'] = $date->addWeek(1)->getTimestamp();
         $data['ip_address'] = ip2long(Zend_Controller_Front::getInstance()->getRequest()->getClientIp());
     } else {
         $data['updated_at'] = $date->getTimestamp();
     }
     $date = null;
     return $this->getTable('Question')->saveRow($data, $row);
 }
开发者ID:rickyfeng,项目名称:wenda,代码行数:29,代码来源:Question.php


注:本文中的Zend_Date::addWeek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。