intl
PHP Manual

The IntlCalendar class

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

Introduction

Class synopsis

IntlCalendar {
/* Constants */
const integer FIELD_ERA = 0 ;
const integer FIELD_YEAR = 1 ;
const integer FIELD_MONTH = 2 ;
const integer FIELD_WEEK_OF_YEAR = 3 ;
const integer FIELD_WEEK_OF_MONTH = 4 ;
const integer FIELD_DATE = 5 ;
const integer FIELD_DAY_OF_YEAR = 6 ;
const integer FIELD_DAY_OF_WEEK = 7 ;
const integer FIELD_DAY_OF_WEEK_IN_MONTH = 8 ;
const integer FIELD_AM_PM = 9 ;
const integer FIELD_HOUR = 10 ;
const integer FIELD_HOUR_OF_DAY = 11 ;
const integer FIELD_MINUTE = 12 ;
const integer FIELD_SECOND = 13 ;
const integer FIELD_MILLISECOND = 14 ;
const integer FIELD_ZONE_OFFSET = 15 ;
const integer FIELD_DST_OFFSET = 16 ;
const integer FIELD_YEAR_WOY = 17 ;
const integer FIELD_DOW_LOCAL = 18 ;
const integer FIELD_EXTENDED_YEAR = 19 ;
const integer FIELD_JULIAN_DAY = 20 ;
const integer FIELD_MILLISECONDS_IN_DAY = 21 ;
const integer FIELD_IS_LEAP_MONTH = 22 ;
const integer FIELD_FIELD_COUNT = 23 ;
const integer FIELD_DAY_OF_MONTH = 5 ;
const integer DOW_SUNDAY = 1 ;
const integer DOW_MONDAY = 2 ;
const integer DOW_TUESDAY = 3 ;
const integer DOW_WEDNESDAY = 4 ;
const integer DOW_THURSDAY = 5 ;
const integer DOW_FRIDAY = 6 ;
const integer DOW_SATURDAY = 7 ;
const integer DOW_TYPE_WEEKDAY = 0 ;
const integer DOW_TYPE_WEEKEND = 1 ;
const integer DOW_TYPE_WEEKEND_OFFSET = 2 ;
const integer DOW_TYPE_WEEKEND_CEASE = 3 ;
const integer WALLTIME_FIRST = 1 ;
const integer WALLTIME_LAST = 0 ;
const integer WALLTIME_NEXT_VALID = 2 ;
/* Methods */
public bool add ( int $field , int $amount )
bool intlcal_add ( IntlCalendar $cal , int $field , int $amount )
public bool after ( IntlCalendar $other )
bool intlcal_after ( IntlCalendar $cal , IntlCalendar $other )
public bool before ( IntlCalendar $other )
bool intlcal_before ( IntlCalendar $cal , IntlCalendar $other )
public bool clear ([ int $field = NULL ] )
bool intlcal_clear ( IntlCalendar $cal [, int $field = NULL ] )
private __construct ( void )
public static IntlCalendar createInstance ([ mixed $timeZone = NULL [, string $locale = "" ]] )
IntlCalendar intlcal_create_instance ([ mixed $timeZone = NULL [, string $locale = "" ]] )
public bool equals ( IntlCalendar $other )
bool intlcal_equals ( IntlCalendar $cal , IntlCalendar $other )
public int fieldDifference ( float $when , int $field )
int intlcal_field_difference ( IntlCalendar $cal , float $when , int $field )
public static IntlCalendar fromDateTime ( mixed $dateTime )
IntlCalendar intlcal_from_date_time ( mixed $dateTime )
public int get ( int $field )
int intlcal_get ( IntlCalendar> $cal , int $field )
public int getActualMaximum ( int $field )
int intlcal_get_actual_maximum ( IntlCalendar $cal , int $field )
public int getActualMinimum ( int $field )
int intlcal_get_actual_minimum ( IntlCalendar $cal , int $field )
public static array getAvailableLocales ( void )
array intlcal_get_available_locales ( void )
public int getDayOfWeekType ( int $dayOfWeek )
int intlcal_get_day_of_week_type ( IntlCalendar $cal , int $dayOfWeek )
public int getErrorCode ( void )
public string getErrorMessage ( void )
public int getFirstDayOfWeek ( void )
int intlcal_get_first_day_of_week ( IntlCalendar $cal )
public int getGreatestMinimum ( int $field )
int intlcal_get_greatest_minimum ( IntlCalendar $cal , int $field )
public static Iterator getKeywordValuesForLocale ( string $key , string $locale , boolean $commonlyUsed )
Iterator intlcal_get_keyword_values_for_locale ( string $key , string $locale , boolean $commonlyUsed )
public int getLeastMaximum ( int $field )
int intlcal_get_least_maximum ( IntlCalendar $cal , int $field )
public string getLocale ( int $localeType )
string intlcal_get_locale ( IntlCalendar $cal , int $localeType )
public int getMaximum ( int $field )
int intlcal_get_maximum ( IntlCalendar $cal , int $field )
public int getMinimalDaysInFirstWeek ( void )
int intlcal_get_minimal_days_in_first_week ( IntlCalendar $cal )
public int getMinimum ( int $field )
int intlcal_get_minimum ( IntlCalendar $cal , int $field )
public static float getNow ( void )
float intlcal_get_now ( void )
public int getRepeatedWallTimeOption ( void )
int intlcal_get_repeated_wall_time_option ( IntlCalendar $cal )
public int getSkippedWallTimeOption ( void )
int intlcal_get_skipped_wall_time_option ( IntlCalendar $cal )
public float getTime ( void )
float intlcal_get_time ( IntlCalendar $cal )
public IntlTimeZone getTimeZone ( void )
IntlTimeZone intlcal_get_time_zone ( IntlCalendar $cal )
public string getType ( void )
string intlcal_get_type ( IntlCalendar $cal )
public int getWeekendTransition ( string $dayOfWeek )
int intlcal_get_weekend_transition ( IntlCalendar $cal , string $dayOfWeek )
public bool inDaylightTime ( void )
bool intlcal_in_daylight_time ( IntlCalendar $cal )
public bool isEquivalentTo ( IntlCalendar $other )
bool intlcal_is_equivalent_to ( IntlCalendar $cal , IntlCalendar $other )
public bool isLenient ( void )
bool intlcal_is_lenient ( IntlCalendar $cal )
public bool isSet ( int $field )
bool intlcal_is_set ( IntlCalendar $cal , int $field )
public bool isWeekend ([ float $date = NULL ] )
bool intlcal_is_weekend ( IntlCalendar $cal [, float $date = NULL ] )
public bool roll ( int $field , mixed $amountOrUpOrDown )
bool intlcal_roll ( IntlCalendar $cal , int $field , mixed $amountOrUpOrDown )
public bool set ( int $field , int $value )
public bool set ( int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] )
bool intlcal_set ( IntlCalendar $cal , int $field , int $value )
bool intlcal_set ( IntlCalendar $cal , int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] )
public bool setFirstDayOfWeek ( int $dayOfWeek )
bool intlcal_set_first_day_of_week ( IntlCalendar $cal , int $dayOfWeek )
public ReturnType setLenient ( string $isLenient )
ReturnType intlcal_set_lenient ( IntlCalendar $cal , string $isLenient )
public bool setMinimalDaysInFirstWeek ( int $minimalDays )
bool intlcal_get_minimal_days_in_first_week ( IntlCalendar $cal , int $minimalDays )
public bool setRepeatedWallTimeOption ( int $wallTimeOption )
bool intlcal_set_repeated_wall_time_option ( IntlCalendar $cal , int $wallTimeOption )
public bool setSkippedWallTimeOption ( int $wallTimeOption )
bool intlcal_set_skipped_wall_time_option ( IntlCalendar $cal , int $wallTimeOption )
public bool setTime ( float $date )
bool intlcal_set_time ( IntlCalendar $cal , float $date )
public bool setTimeZone ( mixed $timeZone )
bool intlcal_set_time_zone ( IntlCalendar $cal , mixed $timeZone )
public DateTime toDateTime ( void )
DateTime intlcal_to_date_time ( IntlCalendar $cal )
}

Predefined Constants

IntlCalendar::FIELD_ERA

Calendar field numerically representing an era, for instance 1 for AD and 0 for BC in the Gregorian/Julian calendars and 235 for the Heisei (平成) era in the Japanese calendar. Not all calendars have more than one era.

IntlCalendar::FIELD_YEAR

Calendar field for the year. This is not unique across eras. If the calendar type has more than one era, generally the minimum value for this field will be 1.

IntlCalendar::FIELD_MONTH

Calendar field for the month. The month sequence is zero-based, so Janurary (here used to signify the first month of the calendar; this may be called another name, such as Muharram in the Islamic calendar) is represented by 0, February by 1, …, December by 11 and, for calendars that have it, the 13th or leap month by 12.

IntlCalendar::FIELD_WEEK_OF_YEAR

Calendar field for the number of the week of the year. This depends on which day of the week is deemed to start the week and the minimal number of days in a week.

IntlCalendar::FIELD_WEEK_OF_MONTH

Calendar field for the number of the week of the month. This depends on which day of the week is deemed to start the week and the minimal number of days in a week.

IntlCalendar::FIELD_DATE

Calendar field for the day of the month. The same as IntlCalendar::FIELD_DAY_OF_MONTH, which has a clearer name.

IntlCalendar::FIELD_DAY_OF_YEAR

Calendar field for the day of the year. For the Gregorian calendar, starts with 1 and ends with 365 or 366.

IntlCalendar::FIELD_DAY_OF_WEEK

Calendar field for the day of the week. Its values start with 1 (Sunday, see IntlCalendar::DOW_SUNDAY and subsequent constants) and the last valid value is 7 (Saturday).

IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH

Given a day of the week (Sunday, Monday, …), this calendar field assigns an ordinal to such a day of the week in a specific month. Thus, if the value of this field is 1 and the value of the day of the week is 2 (Monday), then the set day of the month is the 1st Monday of the month; the maximum value is 5.

Additionally, the value 0 and negative values are also allowed. The value 0 encompasses the seven days that occur immediately before the first seven days of a month (which therefore have a ‘day of week in month’ with value 1). Negative values starts counting from the end of the month – -1 points to the last occurrence of a day of the week in a month, -2 to the second last, and so on.

Unlike IntlCalendar::FIELD_WEEK_OF_MONTH and IntlCalendar::FIELD_WEEK_OF_YEAR, this value does not depend on IntlCalendar::getFirstDayOfWeek() or on IntlCalendar::getMinimalDaysInFirstWeek(). The first Monday is the first Monday, even if it occurs in a week that belongs to the previous month.

IntlCalendar::FIELD_AM_PM

Calendar field indicating whether a time is before noon (value 0, AM) or after (1). Midnight is AM, noon is PM.

IntlCalendar::FIELD_HOUR

Calendar field for the hour, without specifying whether itʼs in the morning or in the afternoon. Valid values are 0 to 11.

IntlCalendar::FIELD_HOUR_OF_DAY

Calendar field for the full (24h) hour of the day. Valid values are 0 to 23.

IntlCalendar::FIELD_MINUTE

Calendar field for the minutes component of the time.

IntlCalendar::FIELD_SECOND

Calendar field for the seconds component of the time.

IntlCalendar::FIELD_MILLISECOND

Calendar field the milliseconds component of the time.

IntlCalendar::FIELD_ZONE_OFFSET

Calendar field indicating the raw offset of the timezone, in milliseconds. The raw offset is the timezone offset, excluding any offset due to daylight saving time.

IntlCalendar::FIELD_DST_OFFSET

Calendar field for the daylight saving time offset of the calendarʼs timezone, in milliseconds, if active for calendarʼs time.

IntlCalendar::FIELD_YEAR_WOY

Calendar field representing the year for week of year purposes.

IntlCalendar::FIELD_DOW_LOCAL

Calendar field for the localized day of the week. This is a value betwen 1 and 7, 1 being used for the day of the week that matches the value returned by IntlCalendar::getFirstDayOfWeek().

IntlCalendar::FIELD_EXTENDED_YEAR

Calendar field for a year number representation that is continuous across eras. For the Gregorian calendar, the value of this field matches that of IntlCalendar::FIELD_YEAR for AD years; a BC year y is represented by -y + 1.

IntlCalendar::FIELD_JULIAN_DAY

Calendar field for a modified Julian day number. It is different from a conventional Julian day number in that its transitions occur at local zone midnight rather than at noon UTC. It uniquely identifies a date.

IntlCalendar::FIELD_MILLISECONDS_IN_DAY

Calendar field encompassing the information in IntlCalendar::FIELD_HOUR_OF_DAY, IntlCalendar::FIELD_MINUTE, IntlCalendar::FIELD_SECOND and IntlCalendar::FIELD_MILLISECOND. Range is from the 0 to 24 * 3600 * 1000 - 1. It is not the amount of milliseconds ellapsed in the day since on DST transitions it will have discontinuities analog to those of the wall time.

IntlCalendar::FIELD_IS_LEAP_MONTH

Calendar field whose value is 1 for indicating a leap month and 0 otherwise.

IntlCalendar::FIELD_FIELD_COUNT

The total number of fields.

IntlCalendar::FIELD_DAY_OF_MONTH

Alias for IntlCalendar::FIELD_DATE.

IntlCalendar::DOW_SUNDAY

Sunday.

IntlCalendar::DOW_MONDAY

Monday.

IntlCalendar::DOW_TUESDAY

Tuesday.

IntlCalendar::DOW_WEDNESDAY

Wednesday.

IntlCalendar::DOW_THURSDAY

Thursday.

IntlCalendar::DOW_FRIDAY

Friday.

IntlCalendar::DOW_SATURDAY

Saturday.

IntlCalendar::DOW_TYPE_WEEKDAY

Output of IntlCalendar::getDayOfWeekType() indicating a day of week is a weekday.

IntlCalendar::DOW_TYPE_WEEKEND

Output of IntlCalendar::getDayOfWeekType() indicating a day of week belongs to the weekend.

IntlCalendar::DOW_TYPE_WEEKEND_OFFSET

Output of IntlCalendar::getDayOfWeekType() indicating the weekend begins during the given day of week.

IntlCalendar::DOW_TYPE_WEEKEND_CEASE

Output of IntlCalendar::getDayOfWeekType() indicating the weekend ends during the given day of week.

IntlCalendar::WALLTIME_FIRST

Output of IntlCalendar::getSkippedWallTimeOption() indicating that wall times in the skipped range should refer to the same instant as wall times with one hour less and of IntlCalendar::getRepeatedWallTimeOption() indicating the wall times in the repeated range should refer to the instant of the first occurrence of such wall time.

IntlCalendar::WALLTIME_LAST

Output of IntlCalendar::getSkippedWallTimeOption() indicating that wall times in the skipped range should refer to the same instant as wall times with one hour after and of IntlCalendar::getRepeatedWallTimeOption() indicating the wall times in the repeated range should refer to the instant of the second occurrence of such wall time.

IntlCalendar::WALLTIME_NEXT_VALID

Output of IntlCalendar::getSkippedWallTimeOption() indicating that wall times in the skipped range should refer to the instant when the daylight saving time transition occurs (begins).

Table of Contents


intl
PHP Manual