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


PHP Zend_Date::setTimezone方法代码示例

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


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

示例1: convertDateToStoreTimestamp

 public function convertDateToStoreTimestamp($date, $store = null)
 {
     try {
         if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/disable_timestamp_timezone_adjustment')) {
             $dateObj = new Zend_Date();
             $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
             return (int) $dateObj->get(null, Zend_Date::TIMESTAMP);
         }
         $dateObj = new Zend_Date();
         $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
         $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
         $dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store));
         $dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store));
         $gmtOffset = $dateObj->getGmtOffset();
         if ($gmtOffset >= 0) {
             if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/zend_date_gmt_offset')) {
                 // Note: Some Zend_Date versions always return a positive $gmtOffset. Thus, we replace + with - below if affected by this.
                 return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
             } else {
                 return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset;
             }
         } else {
             return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
         }
     } catch (Exception $e) {
         return null;
     }
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:28,代码来源:Date.php

示例2: filter

	/**
	 *
	 * @param string $value
	 * @return Zend_Date
	 */
    public function filter($value){
		$d = new Zend_Date();
		$d->setTimezone('Europe/London');
		$d->set($value, 'yyyy-MM-dd hh-mm-ss');
		$d->setTimezone();
		return $d;
	}
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:12,代码来源:SQLDatetimeToDateObject.php

示例3: getDateFromDb

 /**
  * Convert given date string with UTC timezone into default locale format
  * and locale timezone
  *
  * @param string $date date string in SQL format with UTC timezone
  * @return Zend_Date
  */
 public static function getDateFromDb($date)
 {
     if (!is_string($date)) {
         throw new Zmz_Date_Exception('$date must be a string');
     }
     $tmpDate = new Zend_Date();
     $tmpDate->setTimezone('UTC');
     $tmpDate->set($date, self::SQL_DATETIME);
     $tmpDate->setTimezone(Zmz_Culture::getTimezone());
     return $tmpDate;
 }
开发者ID:BGCX261,项目名称:zmz-svn-to-git,代码行数:18,代码来源:Date.php

示例4: eventCalendarAction

 public function eventCalendarAction()
 {
     $viewer = Engine_Api::_()->user()->getViewer();
     //Get user month
     $oldTz = date_default_timezone_get();
     date_default_timezone_set($viewer->timezone);
     $month = $this->_getParam('month', date('m'));
     $year = $this->_getParam('year', date('y'));
     date_default_timezone_set($oldTz);
     $search = Engine_Api::_()->ynevent()->getDateSearch($month, $year);
     $eventTable = Engine_Api::_()->getItemTable('event');
     //Get first date and last day in month server time zone
     $events = $eventTable->getAllEventsInMonth($search[0], $search[1]);
     // var_dump($events);die;
     $event_count = array();
     $i = 0;
     if (count($events)) {
         $eventDates = array();
         foreach ($events as $event) {
             //convert start time to user time zone
             $dateObject = new Zend_Date(strtotime($event->starttime));
             $dateObject->setTimezone($viewer->timezone);
             $event_count[$dateObject->toString('yyyy-MM-dd')][] = $event->event_id;
         }
         date_default_timezone_set($oldTz);
         foreach ($event_count as $index => $evt) {
             $eventDates[$i]['day'] = $index;
             $eventDates[$i]['event_count'] = count($evt);
             $i++;
         }
         $this->view->eventDates = $eventDates;
     }
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:33,代码来源:WidgetController.php

示例5: getDate

 /**
  * Returns the date.
  *
  * @return Zend_Date
  */
 public function getDate()
 {
     $date = new Zend_Date(0);
     $date->setTimezone('UTC');
     $date->set($this->getText(), $this->_format ? $this->_format : Zend_Date::ISO_8601);
     return $date;
 }
开发者ID:lokamaya,项目名称:zend-mp3,代码行数:12,代码来源:DateFrame.php

示例6: getDateFromDb

 /**
  * Convert given date string with UTC timezone into default locale format
  * and locale timezone
  *
  * @param string $date date string in SQL format with UTC timezone
  * @param string $defaultDate date to use if $date is null
  * @return Zend_Date
  */
 public static function getDateFromDb($date, $defaultDate = null)
 {
     if ($defaultDate == null) {
         $defaultDate = "1970-01-01 00:00:00";
     }
     if (null === $date) {
         $date = $defaultDate;
     }
     if (!is_string($date)) {
         throw new Exception('$date must be a string');
     }
     $tmpDate = new Zend_Date();
     $tmpDate->setTimezone('UTC');
     $tmpDate->set($date, self::SQL_DATETIME);
     $tmpDate->setTimezone(Zmz_Culture::getTimezone());
     return $tmpDate;
 }
开发者ID:massimozappino,项目名称:zmz,代码行数:25,代码来源:Date.php

示例7: convertDateToStoreTimestamp

 public function convertDateToStoreTimestamp($date, $store = null)
 {
     try {
         $dateObj = new Zend_Date();
         $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
         $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
         $dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store));
         $dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store));
         $gmtOffset = $dateObj->getGmtOffset();
         if ($gmtOffset >= 0) {
             return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset;
         } else {
             return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset;
         }
     } catch (Exception $e) {
         return null;
     }
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:18,代码来源:Date.php

示例8: getNow

 public function getNow()
 {
     if ($this->_now === null) {
         require_once 'Zend/Date.php';
         $date = new Zend_Date('en_US');
         $date->setTimezone('UTC');
         $this->_now = $date->get('YYYY-MM-dd HH:mm:ss');
     }
     return $this->_now;
 }
开发者ID:sitengine,项目名称:sitengine,代码行数:10,代码来源:Table.php

示例9: getAtom

 public function getAtom()
 {
     $table = $this->_controller->getFrontController()->getBlogPackage()->getPostsTable();
     $whereClauses = array("publish = '1'", $this->_controller->getDatabase()->quoteInto('blogId = ?', $this->_controller->getEntity()->getAncestorId()));
     $select = $table->select()->order('cdate DESC')->limit(20, 0);
     foreach ($whereClauses as $clause) {
         if ($clause) {
             $select->where($clause);
         }
     }
     $items = $table->fetchAll($select);
     $data = array('title' => $this->_rssTitle, 'link' => $this->_rssLink, 'charset' => 'UTF-8', 'email' => $this->_rssEmail, 'webmaster' => $this->_rssWebmaster, 'generator' => 'sitengine', 'language' => 'en');
     foreach ($items as $item) {
         $row = $table->complementRow($item);
         #Sitengine_Debug::print_r($row);
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorSlug(), Sitengine_Env::PARAM_ID => $row['id']);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_SHARP);
         $uriView = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         require_once 'Zend/Date.php';
         $date = new Zend_Date($item->cdate, 'yyyy-MM-dd HH:mm:ss');
         $date->setTimezone('UTC');
         $cdate = $date->get(Zend_Date::TIMESTAMP);
         $post = array('link' => 'http://' . $_SERVER['SERVER_NAME'] . $uriView, 'comments' => 'http://' . $_SERVER['SERVER_NAME'] . $uriView, 'lastUpdate' => $cdate);
         #print $item->cdate.'<br />';
         #html_entity_decode(strip_tags($row['info']), ENT_COMPAT, 'UTF-8')
         switch ($row['type']) {
             case Sitengine_Blog_Posts_Table::TYPE_VIDEO:
                 $postDetail = array('title' => $row['title'], 'description' => '(Video) ' . $row['teaser'], 'content' => $row['teaser']);
                 break;
             case Sitengine_Blog_Posts_Table::TYPE_AUDIO:
                 $postDetail = array('title' => $row['title'], 'description' => '(Audio) ' . html_entity_decode(strip_tags($row['markup']), ENT_COMPAT, 'UTF-8'), 'content' => $row['markup'], 'enclosure' => array(array('url' => $row['file1OriginalUri'], 'type' => $row['file1OriginalMime'])));
                 break;
             case Sitengine_Blog_Posts_Table::TYPE_LINK:
                 $postDetail = array('title' => $row['title'], 'description' => $row['teaser'], 'content' => $row['teaser']);
                 break;
             case Sitengine_Blog_Posts_Table::TYPE_QUOTE:
                 $postDetail = array('title' => $row['teaser'], 'description' => $row['title'] ? 'Quote By ' . $row['title'] : 'Quote', 'content' => $row['title'] ? 'Quote By ' . $row['title'] : 'Quote');
                 break;
             case Sitengine_Blog_Posts_Table::TYPE_GALLERY:
                 $postDetail = array('title' => $row['title'], 'description' => $row['teaser'], 'content' => $row['markup']);
                 break;
             case Sitengine_Blog_Posts_Table::TYPE_PHOTO:
                 $postDetail = array('title' => $row['title'], 'description' => html_entity_decode(strip_tags($row['markup']), ENT_COMPAT, 'UTF-8'), 'content' => $row['markup']);
                 break;
             case Sitengine_Blog_Posts_Table::TYPE_TEXT:
                 $postDetail = array('title' => $row['title'], 'description' => $row['teaser'], 'content' => $row['markup']);
                 break;
         }
         $data['entries'][] = array_merge($post, $postDetail);
     }
     require_once 'Zend/Uri/Http.php';
     require_once 'Zend/Feed.php';
     $atom = Zend_Feed::importArray($data, 'atom');
     return $atom->send();
 }
开发者ID:sitengine,项目名称:sitengine,代码行数:55,代码来源:IndexView.php

示例10: setDataFromEditmode

 /**
  * @see Document_Tag_Interface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     if (strlen($data) > 5) {
         // ext 2.0 returns the selected date in UTC
         date_default_timezone_set("UTC");
         $this->date = new Pimcore_Date($data, Zend_Date::ISO_8601);
         $this->date->setTimezone(Pimcore_Config::getSystemConfig()->general->timezone);
         // set default timezone
         date_default_timezone_set(Pimcore_Config::getSystemConfig()->general->timezone);
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:16,代码来源:Date.php

示例11: getGivenDate

 public function getGivenDate()
 {
     $viewer = Engine_Api::_()->user()->getViewer();
     $timezone = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_locale_timezone', 'GMT');
     if ($viewer && $viewer->getIdentity() && !empty($viewer->timezone)) {
         $timezone = $viewer->timezone;
     }
     $givenDate = new Zend_Date(strtotime($this->given_date));
     $givenDate->setTimezone($timezone);
     return $givenDate;
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:11,代码来源:Recommendation.php

示例12: saveAction

 public function saveAction()
 {
     $this->_isAllowed();
     if ($data = $this->getRequest()->getPost()) {
         $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
         $localeCode = Mage::app()->getLocale()->getLocaleCode();
         if (empty($data['date_from'])) {
             $from = new Zend_Date();
         } else {
             $from = new Zend_Date($data['date_from'], $dateFormatIso, $localeCode);
         }
         $data['date_from'] = $from->setTimezone('utc')->toString(Varien_Date::DATE_INTERNAL_FORMAT);
         if (empty($data['date_to'])) {
             $to = new Zend_Date();
             $to->addMonth(1);
         } else {
             $to = new Zend_Date($data['date_to'], $dateFormatIso, $localeCode);
         }
         $data['date_to'] = $to->setTimezone('utc')->toString(Varien_Date::DATE_INTERNAL_FORMAT);
         if (!isset($data['store_view'])) {
             $data['store_view'][] = '0';
         }
         if ($data['store_view'][0] == '0') {
             $stores = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true);
             foreach ($stores as $store) {
                 if (is_array($store['value'])) {
                     foreach ($store['value'] as $value) {
                         $data['store_view'][] = $value['value'];
                     }
                 }
             }
         }
         $model = Mage::getModel('promotional/promotional');
         $model->setData($data)->setId($this->getRequest()->getParam('id'));
         try {
             $model->save();
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('promotional')->__('Popup was successfully saved'));
             Mage::getSingleton('adminhtml/session')->setFormData(false);
             if ($this->getRequest()->getParam('back')) {
                 $this->_redirect('*/*/edit', array('id' => $model->getId()));
                 return;
             }
             $this->_redirect('*/*/');
             return;
         } catch (Exception $e) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
             Mage::getSingleton('adminhtml/session')->setFormData($data);
             $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
             return;
         }
     }
     Mage::getSingleton('adminhtml/session')->addError(Mage::helper('promotional')->__('Unable to find Popup to save'));
     $this->_redirect('*/*/');
 }
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:54,代码来源:PromotionalController.php

示例13: formatDate

 /**
  * Format a date based on locale and timezone
  *
  * @param	string	$date		Timestamp
  * @param	string	$timezone	Timezone to use
  * @param	string	$format		Format to output date in
  */
 public function formatDate($date, $timezone = null, $format = null)
 {
     if (!$date) {
         return false;
     }
     $zendDate = new Zend_Date($date, Zend_Date::ISO_8601, Zend_Registry::get('Zend_Locale'));
     if ($timezone) {
         $zendDate->setTimezone($timezone);
     }
     if ($format) {
         return $zendDate->get($format);
     }
     return $zendDate;
 }
开发者ID:GEANT,项目名称:CORE,代码行数:21,代码来源:FormatDate.php

示例14: filterBySince

 /**
  * Filter select object by date since.
  *
  * @param Zend_Db_Select $select
  * @param string $dateSince ISO 8601 formatted date
  * @param string $dateField "added" or "modified"
  */
 public function filterBySince($select, $dateSince, $dateField)
 {
     // Reject invalid date fields.
     if (!in_array($dateField, array('added', 'modified'))) {
         return;
     }
     // Accept an ISO 8601 date, set the tiemzone to the server's default
     // timezone, and format the date to be MySQL timestamp compatible.
     $date = new Zend_Date($dateSince, Zend_Date::ISO_8601);
     $date->setTimezone(date_default_timezone_get());
     $date = $date->get('yyyy-MM-dd HH:mm:ss');
     // Select all dates that are greater than the passed date.
     $select->where("files.{$dateField} > ?", $date);
 }
开发者ID:kluther,项目名称:MappingThe4th,代码行数:21,代码来源:File.php

示例15: indexAction

 public function indexAction()
 {
     // Prepare data
     $this->view->event = $event = Engine_Api::_()->core()->getSubject();
     $this->view->fullAddress = $event->getFullAddress();
     // Convert the dates for the viewer
     $tz = date_default_timezone_get();
     $viewer = Engine_Api::_()->user()->getViewer();
     $startDateObject = new Zend_Date(strtotime($event->starttime));
     if ($viewer->getIdentity()) {
         $tz = $viewer->timezone;
     }
     $startDateObject->setTimezone($tz);
     $this->view->startDateObject = $startDateObject;
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:15,代码来源:Controller.php


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