略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: IntlCalendar::getTimeZone

2024-05-04

IntlCalendar::getTimeZone

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)

IntlCalendar::getTimeZoneGet the objectʼs timezone

说明

面向对象风格

public IntlCalendar::getTimeZone(): IntlTimeZone|false

过程化风格

intlcal_get_time_zone(IntlCalendar $calendar): IntlTimeZone|false

Returns the IntlTimeZone object associated with this calendar.

参数

calendar

IntlCalendar 实例。

返回值

An IntlTimeZone object corresponding to the one used internally in this object. Returns false on failure.

范例

示例 #1 IntlCalendar::getTimeZone()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''en_US');

$cal IntlCalendar::createInstance();
print_r($cal->getTimeZone());

$cal->setTimeZone('UTC');
print_r($cal->getTimeZone());

$cal IntlCalendar::fromDateTime('2012-01-01 00:00:00 GMT+03:33');
print_r($cal->getTimeZone());

以上例程会输出:

IntlTimeZone Object
(
    [valid] => 1
    [id] => Europe/Lisbon
    [rawOffset] => 0
    [currentOffset] => 3600000
)
IntlTimeZone Object
(
    [valid] => 1
    [id] => UTC
    [rawOffset] => 0
    [currentOffset] => 0
)
IntlTimeZone Object
(
    [valid] => 1
    [id] => GMT+03:33
    [rawOffset] => 12780000
    [currentOffset] => 12780000
)

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/intlcalendar.gettimezone.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3