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


PHP Zend_Date::getGmtOffset方法代码示例

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


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

示例3: testGmtOffsetValues

 /**
  * Test for False Month Addition
  */
 public function testGmtOffsetValues()
 {
     date_default_timezone_set('Pacific/Auckland');
     $time = time();
     $date = new Zend_Date($time);
     $stamp = $date->getGmtOffset();
     $localtime = localtime($time, true);
     $offset = mktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 1, $localtime['tm_mday'], $localtime['tm_year'] + 1900) - gmmktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 1, $localtime['tm_mday'], $localtime['tm_year'] + 1900);
     $this->assertEquals($stamp, $offset);
     $date->addMonth(6);
     $stamp = $date->getGmtOffset();
     $localtime = localtime($time, true);
     $offset = mktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 7, $localtime['tm_mday'], $localtime['tm_year'] + 1900) - gmmktime($localtime['tm_hour'], $localtime['tm_min'], $localtime['tm_sec'], $localtime['tm_mon'] + 7, $localtime['tm_mday'], $localtime['tm_year'] + 1900);
     $this->assertEquals($stamp, $offset);
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:18,代码来源:DateTest.php

示例4: getTimeZoneOffset

 /**
  * Retrives global timezone offset in seconds
  *
  * @param boolean $isMysql If true retrives mysql formmatted offset (+00:00) in hours
  * @return int
  */
 public function getTimeZoneOffset($isMysql = false)
 {
     $date = new Zend_Date();
     $date->setTimezone($this->getTimezone());
     if ($isMysql) {
         $offsetInt = -$date->getGmtOffset();
         $offset = ($offsetInt >= 0 ? '+' : '-') . sprintf('%02.0f', round(abs($offsetInt / 3600))) . ':' . sprintf('%02.0f', abs(round((abs($offsetInt) - round(abs($offsetInt / 3600)) * 3600) / 60)));
         return $offset;
     } else {
         return $date->getGmtOffset();
     }
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:18,代码来源:Data.php

示例5: diffDays

 /**
  * The number of days in $date subtracted from $this.
  *
  * Zero when both date/times occur on the same day.
  * POSITIVE when $date is YOUNGER than $this
  * Negative when $date is older than $this
  *
  * This function ignores the Timezone and is only concerned with
  * the actual display date of the date: 2 timestamps in different
  * timezones can be the same GMT second, but can still occur on
  * different days.
  *
  * @param \Zend_Date $date
  * @param \Zend_Locale $locale optional (not used)
  * @return type
  */
 public function diffDays(\Zend_Date $date = null, $locale = null)
 {
     $val1 = (int) (($this->getUnixTimestamp() - $this->getGmtOffset()) / self::DAY_SECONDS);
     if (null === $date) {
         // We must use date objects as unix timestamps do not take
         // account of leap seconds.
         $val2 = (int) (time() / self::DAY_SECONDS);
     } else {
         $val2 = (int) (($date->getUnixTimestamp() - $date->getGmtOffset()) / self::DAY_SECONDS);
     }
     return $val1 - $val2;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:28,代码来源:Date.php


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