略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: IntlCalendar::inDaylightTime

2024-11-14

IntlCalendar::inDaylightTime

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

IntlCalendar::inDaylightTimeWhether the objectʼs time is in Daylight Savings Time

说明

面向对象风格

public IntlCalendar::inDaylightTime(): bool

过程化风格

intlcal_in_daylight_time(IntlCalendar $calendar): bool

Whether, for the instant represented by this object and for this objectʼs timezone, daylight saving time is in place.

参数

calendar

IntlCalendar 实例。

返回值

Returns true if the date is in Daylight Savings Time, false otherwise.

On failure false is also returned. To detect error conditions use intl_get_error_code(), or set up Intl to throw exceptions.

范例

示例 #1 IntlCalendar::inDaylightTime()

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

$cal = new IntlGregorianCalendar(2013/* July */145631);
var_dump($cal->inDaylightTime()); // true
$cal->set(IntlCalendar::FIELD_MONTH11 /* December */);
var_dump($cal->inDaylightTime()); // false

//DST end transition on 2013-10-27 at 0200 (wall time back 1 hour)
$cal = new IntlGregorianCalendar(2013/* October */271300);

var_dump($cal->inDaylightTime()); // false (default WALLTIME_LAST)

$cal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_FIRST);
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY1); // force time recalculation
var_dump($cal->inDaylightTime()); // true
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

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

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