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


PHP DateTimeInterface::getTimezone方法代码示例

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


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

示例1: __construct

 public function __construct(\DateTimeInterface $date = NULL)
 {
     if ($date === NULL) {
         $this->date = new \DateTimeImmutable();
     } else {
         $this->date = new \DateTimeImmutable('@' . $date->getTimestamp(), $date->getTimezone());
     }
 }
开发者ID:koolkode,项目名称:http,代码行数:8,代码来源:AbstractDateHeader.php

示例2: init

 /**
  * Init.
  *
  * @param TwitterMessageId   $id
  * @param TwitterUser        $sender
  * @param string             $text
  * @param TwitterEntities    $entities
  * @param \DateTimeInterface $date
  */
 public function init(TwitterMessageId $id, TwitterUser $sender, $text, TwitterEntities $entities, \DateTimeInterface $date)
 {
     Assertion::eq(new \DateTimeZone('UTC'), $date->getTimezone());
     $this->entities = $entities;
     $this->id = $id;
     $this->sender = $sender;
     $this->text = $text;
     $this->date = $date;
 }
开发者ID:remi-san,项目名称:twitter,代码行数:18,代码来源:AbstractMessage.php

示例3: monday

 public static function monday(\DateTimeInterface $date = null)
 {
     if ($date) {
         $today = DateTime::createFromFormat('U', $date->format('U'), $date->getTimezone())->asDate()->asDateTime();
     } else {
         $today = self::today();
     }
     if ($today->format('w') < 1) {
         $monday = $today->modify('-6 day');
     } else {
         $monday = $today->modify('-' . ($today->format('w') - 1) . ' day');
     }
     return $monday;
 }
开发者ID:staffim,项目名称:datetime,代码行数:14,代码来源:Calendar.php

示例4: computeExpires

 protected function computeExpires(\DateTimeInterface $expires = NULL)
 {
     // TODO: Lock min / max timeouts must be configurable.
     $min = new \DateTimeImmutable('+2 minutes');
     if ($expires === NULL || $expires < $min) {
         return $min;
     }
     $max = new \DateTimeImmutable('+2 hours');
     if ($expires > $max) {
         return $max;
     }
     return new \DateTimeImmutable('@' . $expires->getTimestamp(), $expires->getTimezone());
 }
开发者ID:koolkode,项目名称:webdav,代码行数:13,代码来源:DatabaseStorage.php

示例5: extractTimezone

 /**
  * @param \DateTimeInterface $dateTime
  *
  * @return string
  */
 private function extractTimezone(\DateTimeInterface $dateTime)
 {
     return $dateTime->getTimezone()->getName();
 }
开发者ID:kyoya-de,项目名称:date-time,代码行数:9,代码来源:DateTimeFormatter.php

示例6: formatDateTime

 /**
  * @param \DateTimeInterface $date
  * @param int $dateType
  * @param int $timeType
  * @param null $locale
  * @param null $timezone
  * @param string|null $pattern
  * @return string
  */
 public function formatDateTime(
     \DateTimeInterface $date,
     $dateType = \IntlDateFormatter::SHORT,
     $timeType = \IntlDateFormatter::SHORT,
     $locale = null,
     $timezone = null,
     $pattern = null
 ) {
     $formatter = new \IntlDateFormatter(
         $locale ?: $this->_localeResolver->getLocale(),
         $dateType,
         $timeType,
         $timezone ?: $date->getTimezone(),
         null,
         $pattern
     );
     return $formatter->format($date);
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:27,代码来源:Timezone.php

示例7: formatDateTime

 /**
  * @param \DateTimeInterface $date
  * @param int $dateType
  * @param int $timeType
  * @param null $locale
  * @param null $timezone
  * @param string|null $pattern
  * @return string
  */
 public function formatDateTime(\DateTimeInterface $date, $dateType = \IntlDateFormatter::SHORT, $timeType = \IntlDateFormatter::SHORT, $locale = null, $timezone = null, $pattern = null)
 {
     if ($timezone === null) {
         if ($date->getTimezone() === null || $date->getTimezone()->getName() === '+00:00') {
             $timezone = new \DateTimeZone('UTC');
         } else {
             $timezone = $date->getTimezone();
         }
     }
     $formatter = new \IntlDateFormatter($locale ?: $this->_localeResolver->getLocale(), $dateType, $timeType, $timezone, null, $pattern);
     return $formatter->format($date);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:21,代码来源:Timezone.php

示例8: date_timezone_get

function date_timezone_get(DateTimeInterface $datetime)
{
    return $datetime->getTimezone();
}
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:datetime_funcs.php

示例9: setExpires

 public function setExpires(\DateTimeInterface $expires)
 {
     $this->expires = new \DateTimeImmutable('@' . $expires->getTimestamp(), $expires->getTimezone());
 }
开发者ID:koolkode,项目名称:webdav,代码行数:4,代码来源:LockInfo.php

示例10: setEnd

 /**
  * Set the end date for the range
  *
  * @param \DateTimeInterface $end
  * @return DateRange
  */
 public function setEnd(\DateTimeInterface $end)
 {
     $this->endTimezone = $end->getTimezone();
     $this->end = (new \DateTimeImmutable($end->format('c')))->setTimezone(new \DateTimeZone('UTC'));
     return $this;
 }
开发者ID:gubler,项目名称:date-range,代码行数:12,代码来源:DateRange.php

示例11: createFormatter

 /**
  * @param \DateTimeInterface $dateTime
  * @param int                $dateType
  * @param int                $timeType
  * @param string             $pattern
  *
  * @return \IntlDateFormatter
  */
 private function createFormatter($dateTime, $dateType = self::NONE, $timeType = self::NONE, $pattern = null)
 {
     return new \IntlDateFormatter($this->locale, $dateType, $timeType, $dateTime->getTimezone(), \IntlDateFormatter::GREGORIAN, $pattern);
 }
开发者ID:demontpx,项目名称:util-bundle,代码行数:12,代码来源:SimpleDateFormatter.php

示例12: expiresAt

 /**
  * Sets the expiration time for this cache item.
  *
  * @param \DateTimeInterface $expiration
  *   The point in time after which the item MUST be considered expired.
  *   If null is passed explicitly, a default value MAY be used. If none is set,
  *   the value should be stored permanently or for as long as the
  *   implementation allows.
  *
  * @return static
  *   The called object.
  */
 public function expiresAt($expiration)
 {
     $now = new \DateTime('now', $expiration->getTimezone());
     $this->cacheLifetime = $expiration->getTimestamp() - $now->getTimestamp();
     return $this;
 }
开发者ID:ecomdev,项目名称:magento-psr6-bridge,代码行数:18,代码来源:CacheItem.php


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