The IntlGregorianCalendar class

(PHP 5 >= 5.5.0, PHP 7)

Introducere

Sinopsisul clasei

IntlGregorianCalendar extends IntlCalendar {
/* Constante moștenite */
const int IntlCalendar::FIELD_ERA = 0 ;
const int IntlCalendar::FIELD_YEAR = 1 ;
const int IntlCalendar::FIELD_MONTH = 2 ;
const int IntlCalendar::FIELD_DATE = 5 ;
const int IntlCalendar::FIELD_AM_PM = 9 ;
const int IntlCalendar::FIELD_HOUR = 10 ;
const int IntlCalendar::FIELD_MINUTE = 12 ;
const int IntlCalendar::FIELD_SECOND = 13 ;
const int IntlCalendar::DOW_SUNDAY = 1 ;
const int IntlCalendar::DOW_MONDAY = 2 ;
const int IntlCalendar::DOW_TUESDAY = 3 ;
const int IntlCalendar::DOW_FRIDAY = 6 ;
/* Metode */
public __construct ( IntlTimeZone $tz = ? , string $locale = ? )
public getGregorianChange ( ) : float|false
public isLeapYear ( int $year ) : bool
public setGregorianChange ( float $date ) : bool
/* Metode moștenite */
public IntlCalendar::add ( int $field , int $amount ) : bool
intlcal_add ( IntlCalendar $cal , int $field , int $amount ) : bool
public IntlCalendar::after ( IntlCalendar $other ) : bool
intlcal_after ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::before ( IntlCalendar $other ) : bool
intlcal_before ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::clear ( int $field = NULL ) : bool
intlcal_clear ( IntlCalendar $cal , int $field = NULL ) : bool
public static IntlCalendar::createInstance ( mixed $timeZone = NULL , string $locale = "" ) : IntlCalendar
intlcal_create_instance ( mixed $timeZone = NULL , string $locale = "" ) : IntlCalendar
public IntlCalendar::equals ( IntlCalendar $other ) : bool
intlcal_equals ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::fieldDifference ( float $when , int $field ) : int|false
intlcal_field_difference ( IntlCalendar $cal , float $when , int $field ) : int|false
public static IntlCalendar::fromDateTime ( mixed $dateTime ) : IntlCalendar
intlcal_from_date_time ( mixed $dateTime ) : IntlCalendar
public IntlCalendar::get ( int $field ) : int
intlcal_get ( IntlCalendar $cal , int $field ) : int
public IntlCalendar::getActualMaximum ( int $field ) : int|false
intlcal_get_actual_maximum ( IntlCalendar $cal , int $field ) : int|false
public IntlCalendar::getActualMinimum ( int $field ) : int|false
intlcal_get_actual_minimum ( IntlCalendar $cal , int $field ) : int|false
public static IntlCalendar::getAvailableLocales ( ) : array
intlcal_get_available_locales ( ) : array
public IntlCalendar::getDayOfWeekType ( int $dayOfWeek ) : int|false
intlcal_get_day_of_week_type ( IntlCalendar $cal , int $dayOfWeek ) : int|false
public IntlCalendar::getErrorCode ( ) : int
public IntlCalendar::getErrorMessage ( ) : string
public IntlCalendar::getFirstDayOfWeek ( ) : int|false
intlcal_get_first_day_of_week ( IntlCalendar $cal ) : int|false
public IntlCalendar::getGreatestMinimum ( int $field ) : int|false
intlcal_get_greatest_minimum ( IntlCalendar $cal , int $field ) : int|false
public static IntlCalendar::getKeywordValuesForLocale ( string $key , string $locale , bool $commonlyUsed ) : Iterator|false
static intlcal_get_keyword_values_for_locale ( string $key , string $locale , bool $commonlyUsed ) : Iterator|false
public IntlCalendar::getLeastMaximum ( int $field ) : int|false
intlcal_get_least_maximum ( IntlCalendar $cal , int $field ) : int|false
public IntlCalendar::getLocale ( int $localeType ) : string|false
intlcal_get_locale ( IntlCalendar $cal , int $localeType ) : string|false
public IntlCalendar::getMaximum ( int $field ) : int|false
intlcal_get_maximum ( IntlCalendar $cal , int $field ) : int|false
intlcal_get_minimal_days_in_first_week ( IntlCalendar $cal ) : int|false
public IntlCalendar::getMinimum ( int $field ) : int|false
intlcal_get_minimum ( IntlCalendar $cal , int $field ) : int|false
public static IntlCalendar::getNow ( ) : float
intlcal_get_now ( ) : float
intlcal_get_repeated_wall_time_option ( IntlCalendar $cal ) : int
intlcal_get_skipped_wall_time_option ( IntlCalendar $cal ) : int
public IntlCalendar::getTime ( ) : float
intlcal_get_time ( IntlCalendar $cal ) : float
intlcal_get_time_zone ( IntlCalendar $cal ) : IntlTimeZone
public IntlCalendar::getType ( ) : string
intlcal_get_type ( IntlCalendar $cal ) : string
public IntlCalendar::getWeekendTransition ( string $dayOfWeek ) : int|false
intlcal_get_weekend_transition ( IntlCalendar $cal , string $dayOfWeek ) : int|false
public IntlCalendar::inDaylightTime ( ) : bool
intlcal_in_daylight_time ( IntlCalendar $cal ) : bool
public IntlCalendar::isEquivalentTo ( IntlCalendar $other ) : bool
intlcal_is_equivalent_to ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::isLenient ( ) : bool
intlcal_is_lenient ( IntlCalendar $cal ) : bool
public IntlCalendar::isSet ( int $field ) : bool
intlcal_is_set ( IntlCalendar $cal , int $field ) : bool
public IntlCalendar::isWeekend ( float $date = NULL ) : bool
intlcal_is_weekend ( IntlCalendar $cal , float $date = NULL ) : bool
public IntlCalendar::roll ( int $field , mixed $amountOrUpOrDown ) : bool
intlcal_roll ( IntlCalendar $cal , int $field , mixed $amountOrUpOrDown ) : bool
public IntlCalendar::set ( int $field , int $value ) : bool
public IntlCalendar::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 ) : bool
public IntlCalendar::setFirstDayOfWeek ( int $dayOfWeek ) : bool
intlcal_set_first_day_of_week ( IntlCalendar $cal , int $dayOfWeek ) : bool
public IntlCalendar::setLenient ( bool $isLenient ) : bool
intlcal_set_lenient ( IntlCalendar $cal , bool $isLenient ) : bool
public IntlCalendar::setMinimalDaysInFirstWeek ( int $minimalDays ) : bool
intlcal_set_minimal_days_in_first_week ( IntlCalendar $cal , int $minimalDays ) : bool
public IntlCalendar::setRepeatedWallTimeOption ( int $wallTimeOption ) : bool
intlcal_set_repeated_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool
public IntlCalendar::setSkippedWallTimeOption ( int $wallTimeOption ) : bool
intlcal_set_skipped_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool
public IntlCalendar::setTime ( float $date ) : bool
intlcal_set_time ( IntlCalendar $cal , float $date ) : bool
public IntlCalendar::setTimeZone ( mixed $timeZone ) : bool
intlcal_set_time_zone ( IntlCalendar $cal , mixed $timeZone ) : bool
intlcal_to_date_time ( IntlCalendar $cal ) : DateTime
}

Cuprins

add a note add a note

User Contributed Notes 1 note

up
0
Julian Sawicki
4 years ago
I was using `IntlGregorianCalendar` because it offered a nice way to get the week number of the year as an integer. This differs from `DateTime`; `DateTime` gives you the week number of the year as an string.

<?php

$dateTime
= new DateTime('21-09-2020 09:00:00');
echo
$dateTime->format("W"); // string '39'

$intlCalendar = IntlCalendar::fromDateTime ('21-09-2020 09:00:00');
echo
$intlCalendar->get(IntlCalendar::FIELD_WEEK_OF_YEAR); // integer 39
To Top