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


PHP Zend_Date::setMonth方法代码示例

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


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

示例1: getIntervals

 public function getIntervals()
 {
     if (!$this->_intervals) {
         $this->_intervals = array();
         if (!$this->_from && !$this->_to) {
             return $this->_intervals;
         }
         $dateStart = new Zend_Date($this->_from);
         $dateEnd = new Zend_Date($this->_to);
         $t = array();
         $firstInterval = true;
         /** START AITOC FIX **/
         if (in_array((string) $this->_period, array('day', 'month', 'year'))) {
             /** END AITOC FIX **/
             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 'month':
                         $t['title'] = $dateStart->toString('MM/yyyy');
                         $t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-MM-01 00:00:00');
                         $lastInterval = $dateStart->compareMonth($dateEnd->getMonth()) == 0;
                         $t['end'] = $lastInterval ? $dateStart->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                         $dateStart->addMonth(1);
                         if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
                             $dateStart->setDay(1);
                         }
                         $firstInterval = false;
                         break;
                     case 'year':
                         $t['title'] = $dateStart->toString('yyyy');
                         $t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-01-01 00:00:00');
                         $lastInterval = $dateStart->compareYear($dateEnd->getYear()) == 0;
                         $t['end'] = $lastInterval ? $dateStart->setMonth($dateEnd->getMonth())->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-12-31 23:59:59');
                         $dateStart->addYear(1);
                         if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
                             $dateStart->setMonth(1)->setDay(1);
                         }
                         $firstInterval = false;
                         break;
                 }
                 $this->_intervals[$t['title']] = $t;
             }
             /** START AITOC FIX **/
         }
         /** END AITOC FIX **/
     }
     return $this->_intervals;
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:53,代码来源:ReportsReportCollection.php

示例2: indexAction

 /**
  * Enter description here...
  *
  */
 public function indexAction()
 {
     $currentDate = new Zend_Date();
     $currentMonth = $currentDate->toString(Zend_Date::MONTH_SHORT);
     $currentDay = $currentDate->toString(Zend_Date::DAY_SHORT);
     $month = $this->_getParam('month', $currentMonth);
     if (false === is_numeric($month)) {
         $month = $this->_monthMap[urldecode($month)];
     }
     $currentDate->setMonth($month);
     $currentDate->setDay(1);
     $days = $currentDate->toString(Zend_Date::MONTH_DAYS);
     $this->view->selectedMonth = $month;
     $this->view->currentMonth = $currentMonth;
     $this->view->currentDay = $currentDay;
     $result = Bc_UserDTO::fetchAsArray(array('month' => $month));
     $month = array();
     for ($i = 1; $i <= $days; $i++) {
         $data = array();
         $data['date'] = $currentDate->toString(Zend_Date::DAY . '.' . Zend_Date::MONTH . '.' . Zend_Date::YEAR);
         $user = array();
         foreach ($result as $birthday) {
             if ($i == $birthday['birthday']) {
                 $user[] = $birthday;
             }
         }
         $data['user'] = empty($user) ? null : $user;
         $month[$i] = $data;
         $currentDate->add('24:00:00', Zend_Date::TIMES);
     }
     $this->view->month = $month;
 }
开发者ID:noon,项目名称:phpMyBirthday,代码行数:36,代码来源:IndexController.php

示例3: testZF7154

 /**
  * @ZF-7154
  */
 public function testZF7154()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1577833200, $locale);
     $date2 = new Zend_Date(2006, Zend_Date::YEAR);
     $date->setTimeZone(date_default_timezone_get());
     $date->setYear(2000);
     $date->setMonth('Apr.');
     $this->assertSame('2000-04-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
     $date->setYear(2004);
     $date->setMonth('Februar');
     $this->assertSame('2004-02-01T04:00:00+05:00', $date->get(Zend_Date::W3C));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:16,代码来源:DateTest.php

示例4: testLoose


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

示例5: getListByDate

 /**
  * @param string $year
  * @param string $month
  * @param integer $page
  * @param integer $perPage
  * @return Zend_Paginator
  */
 public function getListByDate($year, $month = null, $page = 1, $perPage = 10)
 {
     $month = (int) $month;
     if ($month < 1 || $month > 12) {
         $month = 0;
         $date = new Zend_Date("{$year}-01-01", Zend_Date::ISO_8601);
     } else {
         if (1 == strlen($month)) {
             $month = "0{$month}";
         }
         $date = new Zend_Date("{$year}-{$month}-01", Zend_Date::ISO_8601);
     }
     $from = (int) $date->getTimestamp();
     if ($month) {
         $to = (int) $date->setDay($date->get(Zend_Date::MONTH_DAYS))->getTimestamp();
     } else {
         $to = (int) $date->setMonth(12)->setDay(31)->getTimestamp();
     }
     $list = $this->_getList();
     $list->setCondition('date BETWEEN ? AND ?', array($from, $to));
     return $this->_paginate($list, $page, $perPage);
 }
开发者ID:Cube-Solutions,项目名称:blog,代码行数:29,代码来源:Blog.php

示例6: getCalendar

 public function getCalendar($month = null, $year = null, $location = null)
 {
     $zd = new Zend_Date();
     if (is_null($month)) {
         $month = date('n');
     }
     if (is_null($year)) {
         $year = date('Y');
     }
     $zd->setMonth($month);
     $zd->setYear($year);
     $zd->setDay(1);
     $calData = array();
     $calData['startDay'] = $zd->get(Zend_Date::WEEKDAY_DIGIT);
     $calData['month'] = $zd->get(Zend_Date::MONTH_SHORT);
     $calData['monthName'] = $zd->get(Zend_Date::MONTH_NAME);
     $calData['monthDays'] = $zd->get(Zend_Date::MONTH_DAYS);
     $calData['year'] = $zd->get(Zend_Date::YEAR);
     if ($calData['month'] == 12) {
         $calData['nextMonth'] = 1;
     } else {
         $calData['nextMonth'] = $calData['month'] + 1;
     }
     $calData['nextYear'] = $calData['year'];
     if ($calData['nextMonth'] == 1) {
         $calData['nextYear'] = $calData['year'] + 1;
     }
     if ($calData['month'] == 1) {
         $calData['prevMonth'] = 12;
     } else {
         $calData['prevMonth'] = $calData['month'] - 1;
     }
     $calData['prevYear'] = $calData['year'];
     if ($calData['prevMonth'] == 12) {
         $calData['prevYear'] = $calData['year'] - 1;
     }
     $tmpDate = new Zend_Date();
     $calData['week'] = $tmpDate->get(Zend_Date::WEEK);
     $calData['rows'] = array();
     $dayCounter = 1;
     // make sure we don't have an empty row
     if ($calData['startDay'] > 4) {
         $numRows = intval($calData['monthDays'] / 5);
     } else {
         $numRows = intval($calData['monthDays'] / 6);
     }
     for ($x = 0; $x < $numRows; $x++) {
         $sd = 0;
         if ($x == 0) {
             // this sets the first row to start on the correct day of the week
             for ($y = 0; $y < $calData['startDay']; $y++) {
                 $tmp = array();
                 $tmp['num'] = "";
                 $calData['rows'][$x]['days'][$y] = $tmp;
             }
             $sd = $calData['startDay'];
         }
         $event = new Event();
         // put the numbers in the rows
         for ($z = $sd; $z < 7; $z++) {
             $tmp = array();
             if ($dayCounter <= $calData['monthDays']) {
                 $zd->setDay($dayCounter);
                 // set the week number
                 $calData['rows'][$x]['weekNum'] = $zd->get(Zend_Date::WEEK);
                 $calData['rows'][$x]['weekYear'] = $zd->get(Zend_Date::YEAR);
                 if (isset($calData['rows'][$x - 1]['weekNum'])) {
                     if ($calData['rows'][$x - 1]['weekNum'] == 52) {
                         $calData['rows'][$x]['weekNum'] = "01";
                         $calData['rows'][$x]['weekYear'] = $year + 1;
                     }
                 }
                 $tmp['num'] = $dayCounter;
                 $calData['rows'][$x]['days'][$z] = $tmp;
                 $where = $event->getAdapter()->quoteInto('date = ?', $year . "-" . $month . "-" . $dayCounter);
                 $where .= " AND ";
                 $where .= $event->getAdapter()->quoteInto('status = ?', 'open');
                 if (!is_null($locationId)) {
                     $where .= " AND ";
                     $where .= $event->getAdapter()->quoteInto('locationId = ?', $locationId);
                 }
                 $events = $event->fetchAll($where, 'startTime')->toArray();
                 $calData['rows'][$x]['days'][$z]['numEvents'] = count($events);
             } else {
                 $tmp['num'] = "";
                 $calData['rows'][$x]['days'][$z] = $tmp;
             }
             $dayCounter++;
         }
     }
     return $calData;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:92,代码来源:Calendar.php

示例7: indexAction

 /**
  * The main scheduler page.  This allows a user to view and edit the schedule.  Users
  * will almost certainly need access to this entire controller to make the
  * scheduler work properly and look right.
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('addEvent' => $this->_helper->hasAccess('add-event'));
     $get = Zend_Registry::get('getFilter');
     if (isset($get->workshopId)) {
         $workshopId = $get->workshopId;
         $this->view->workshopId = $workshopId;
         $this->view->startInAddMode = 1;
     }
     if (isset($get->startYear)) {
         $this->view->startYear = $get->startYear;
     } else {
         $this->view->startYear = date('Y');
     }
     if (isset($get->startMonth)) {
         $this->view->startMonth = $get->startMonth;
     } else {
         $this->view->startMonth = date('m');
     }
     $eventId = null;
     if (isset($get->eventId)) {
         $eventId = $get->eventId;
         $this->view->eventId = $eventId;
         $this->view->startInEditMode = 1;
         $e = new Event();
         $thisEvent = $e->find($eventId)->toArray();
         $this->view->locationId = $thisEvent['locationId'];
     }
     $zd = new Zend_Date();
     $this->view->workshopLength = mktime(1, 0, 0, 1, 1, 1970);
     $this->view->startTime = mktime(0, 0, 0, 1, 1, 1970);
     $this->view->endTime = mktime(23, 30, 0, 1, 1, 1970);
     $this->view->baseTime = mktime(0, 0, 0, 1, 1, 1970);
     $this->view->today = $zd->get(Zend_Date::MONTH) . "/" . $zd->get(Zend_Date::DAY) . "/" . $zd->get(Zend_Date::YEAR);
     $this->view->thisYear = $zd->get(Zend_Date::YEAR);
     $this->view->thisWeek = $zd->get(Zend_Date::WEEK);
     if (!is_null($eventId)) {
         $tmpDate = explode('-', $thisEvent['date']);
         $zd->setYear($tmpDate[0]);
         $zd->setMonth($tmpDate[1]);
         $zd->setDay($tmpDate[2]);
     }
     $this->view->year = $zd->get(Zend_Date::YEAR);
     $this->view->week = $zd->get(Zend_Date::WEEK);
     $this->_helper->pageTitle('workshop-schedule-index:title');
     $workshop = new Workshop();
     $where = $workshop->getAdapter()->quoteInto('status = ?', 'enabled');
     $workshops = $workshop->fetchAll($where, 'title');
     $workshopList = array();
     $workshopList[0] = "";
     foreach ($workshops as $w) {
         $workshopList[$w->workshopId] = $w->title;
     }
     $this->view->workshops = $workshopList;
     $location = new Location();
     $where = $location->getAdapter()->quoteInto('status = ?', 'enabled');
     $locations = $location->fetchAll($where, 'name');
     if (count($locations) == 0) {
         $this->_helper->redirector->gotoUrl('/workshop/schedule/noLocationsFound');
     }
     foreach ($locations as $l) {
         $locationList[$l->locationId] = $l->name;
     }
     $this->view->locationList = $locationList;
     //get all the users available for the instructor list
     $profile = new Ot_Account();
     $profiles = $profile->fetchAll(null, array('lastName', 'firstName'))->toArray();
     $instructors = array();
     foreach ($profiles as $p) {
         $instructors[$p['username']] = $p['lastName'] . ", " . $p['firstName'];
     }
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->view->instructors = $instructors;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/public/scripts/jMonthCalendar-1.1.0.js');
     //$this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jMonthCalendar-1.2.2.js');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/public/scripts/jquery.bt.min.js');
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:83,代码来源:ScheduleController.php

示例8: _getYearInterval

 /**
  * Get Interval for a year
  *
  * @param Zend_Date $dateStart
  * @param Zend_Date $dateEnd
  * @param bool $firstInterval
  * @return array
  */
 protected function _getYearInterval(Zend_Date $dateStart, Zend_Date $dateEnd, $firstInterval)
 {
     $interval = array();
     $interval['period'] = $dateStart->toString('yyyy');
     $interval['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-01-01 00:00:00');
     $lastInterval = $dateStart->compareYear($dateEnd->getYear()) == 0;
     $interval['end'] = $lastInterval ? $dateStart->setMonth($dateEnd->getMonth())->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-12-31 23:59:59');
     $dateStart->addYear(1);
     if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
         $dateStart->setMonth(1)->setDay(1);
     }
     return $interval;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:21,代码来源:Collection.php

示例9: 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


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