當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。