IntlCalendar::getSkippedWallTimeOption

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

IntlCalendar::getSkippedWallTimeOptionGet behavior for handling skipped wall time

说明

面向对象风格

public IntlCalendar::getSkippedWallTimeOption ( void ) : int

过程化风格

intlcal_get_skipped_wall_time_option ( IntlCalendar $cal ) : int

Gets the current strategy for dealing with wall times that are skipped whenever the clock is forwarded during dailight saving time start transitions. The default value is IntlCalendar::WALLTIME_LAST.

The calendar must be lenient for this option to have any effect, otherwise attempting to set a non-existing time will cause an error.

This function requires ICU 4.9 or later.

参数

cal

The IntlCalendar resource.

返回值

One of the constants IntlCalendar::WALLTIME_FIRST, IntlCalendar::WALLTIME_LAST or IntlCalendar::WALLTIME_NEXT_VALID.

范例

Example #1 IntlCalendar::getSkippedWallTimeOption()

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

//On March 31st at 0100, the clock goes forward 1 hour and from GMT+00 to GMT+01
$cal = new IntlGregorianCalendar(2013/* March */31130);

var_dump(
    
$cal->isLenient(),               // true
    
$cal->getSkippedWalltimeOption() // 0 WALLTIME_LAST
);

$formatter IntlDateFormatter::create(
    
NULL,
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'UTC'
);
var_dump($formatter->format($cal->getTime() / 1000));

$cal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST);
var_dump($cal->getSkippedWalltimeOption()); // 1 WALLTIME_FIRST
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY1);

var_dump($formatter->format($cal->getTime() / 1000));

$cal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_NEXT_VALID);
var_dump($cal->getSkippedWalltimeOption()); // 2 WALLTIME_NEXT_VALID
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY1);

var_dump($formatter->format($cal->getTime() / 1000));

以上例程会输出:

bool(true)
int(0)
string(40) "Sunday, March 31, 2013 at 1:30:00 AM GMT"
int(1)
string(41) "Sunday, March 31, 2013 at 12:30:00 AM GMT"
int(2)
string(40) "Sunday, March 31, 2013 at 1:00:00 AM GMT"

参见

相关文章
php intlcalendar add a signed amount of time to a fieldphp intlcalendar whether this objectʼs time is after that of the passed objectphp intlcalendar whether this objectʼs time is before that of the passed objectphp intlcalendar compare time of two intlcalendar objects for equalityphp intlcalendar calculate difference between given time and this objectʼs timephp intlcalendar the maximum value for a field considering the objectʼs current timephp intlcalendar the minimum value for a field considering the objectʼs current timephp intlcalendar get number representing the current timephp intlcalendar get behavior for handling repeating wall timephp intlcalendar get behavior for handling skipped wall timephp intlcalendar get time of the day at which weekend begins or endsphp intlcalendar whether the objectʼs time is in daylight savings timephp intlcalendar whether another calendar is equal but for a different timephp intlcalendar whether date/time interpretation is in lenient modephp intlcalendar whether a certain date/time is in the weekendphp intlcalendar set a time field or several common fields at oncephp intlcalendar set whether date/time interpretation is to be lenientphp intlcalendar set behavior for handling repeating wall times at negative timezone offset transitionsphp intlcalendar set behavior for handling skipped wall times at positive timezone offset transitionsphp intltimezone get the amount of time to be added to local standard time to get local wall clock time
关注编程学问公众号