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