首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

IntlDateFormatter::getTimeZone

(PHP 5 >= 5.5.0, PHP 7, PECL intl >= 3.0.0)

IntlDateFormatter::getTimeZone -- datefmt_get_timezone — Get formatter?s timezone

Description

Object oriented style

代码语言:javascript
复制
public IntlTimeZone IntlDateFormatter::getTimeZone ( void )

Procedural style

代码语言:javascript
复制
IntlTimeZone datefmt_get_timezone ( void )

Returns an IntlTimeZone object representing the timezone that will be used by this object to format dates and times. When formatting IntlCalendar and DateTime objects with this IntlDateFormatter, the timezone used will be the one returned by this method, not the one associated with the objects being formatted.

Parameters

This function has no parameters.

Return Values

The associated IntlTimeZone object or FALSE on failure.

Examples

Example #1 IntlDateFormatter::getTimeZone() examples

代码语言:javascript
复制
<?php

$madrid?=?IntlDateFormatter::create(NULL,?NULL,?NULL,?'Europe/Madrid');
$lisbon?=?IntlDateFormatter::create(NULL,?NULL,?NULL,?'Europe/Lisbon');

var_dump($madrid->getTimezone());
echo?$madrid->getTimezone()->getDisplayName(
????????false,?IntlTimeZone::DISPLAY_GENERIC_LOCATION,?"en_US"),?"\n";
echo?$lisbon->getTimeZone()->getId(),?"\n";
//The?id?can?also?be?retrieved?with?->getTimezoneId()
echo?$lisbon->getTimeZoneId(),?"\n";

The above example will output:

代码语言:javascript
复制
object(IntlTimeZone)#4 (4) {
  ["valid"]=>
  bool(true)
  ["id"]=>
  string(13) "Europe/Madrid"
  ["rawOffset"]=>
  int(3600000)
  ["currentOffset"]=>
  int(7200000)
}
Spain Time
Europe/Lisbon
Europe/Lisbon

See Also

  • IntlDateFormatter::getTimeZoneId() - Get the timezone-id used for the IntlDateFormatter
  • IntlDateFormatter::setTimeZone() - Sets formatter?s timezone
  • IntlTimeZone

← IntlDateFormatter::getCalendarObject

IntlDateFormatter::isLenient →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com