Php/docs/intlcalendar.indaylighttime

来自菜鸟教程
跳转至:导航、​搜索

IntlCalendar::inDaylightTime

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

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


说明

面向对象风格

public IntlCalendar::inDaylightTime ( ) : bool

过程化风格

intlcal_in_daylight_time ( IntlCalendar $cal ) : bool

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


参数

cal
The IntlCalendar resource.


返回值

Returns true if the date is in Daylight Savings Time, false otherwise. The value false may also be returned on failure, for instance after specifying invalid field values on non-lenient mode; use exceptions or query intl_get_error_code() to disambiguate.


范例

Example #1 IntlCalendar::inDaylightTime()

<?phpini_set('date.timezone', 'Europe/Lisbon');ini_set('intl.default_locale', 'pt_PT');$cal = new IntlGregorianCalendar(2013, 6 /* July */, 1, 4, 56, 31);var_dump($cal->inDaylightTime()); // true$cal->set(IntlCalendar::FIELD_MONTH, 11 /* December */);var_dump($cal->inDaylightTime()); // false//DST end transition on 2013-10-27 at 0200 (wall time back 1 hour)$cal = new IntlGregorianCalendar(2013, 9 /* October */, 27, 1, 30, 0);var_dump($cal->inDaylightTime()); // false (default WALLTIME_LAST)$cal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_FIRST);$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 1); // force time recalculationvar_dump($cal->inDaylightTime()); // true