PHP 7.4.24 Released!

The IntlGregorianCalendar class

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

简介

类摘要

class IntlGregorianCalendar extends IntlCalendar {
/* 继承的常量 */
const int IntlCalendar::FIELD_ERA = 0;
const int IntlCalendar::FIELD_HOUR = 10;
/* 方法 */
public __construct(IntlTimeZone $tz = ?, string $locale = ?)
public getGregorianChange(): float|false
public isLeapYear(int $year): bool
public setGregorianChange(float $date): bool
/* 继承的方法 */
public IntlCalendar::add(int $field, int $amount): bool
public IntlCalendar::after(IntlCalendar $other): bool
public IntlCalendar::before(IntlCalendar $other): bool
public IntlCalendar::clear(int $field = NULL): bool
public static IntlCalendar::createInstance(mixed $timeZone = NULL, string $locale = ""): IntlCalendar
public IntlCalendar::equals(IntlCalendar $other): bool
public IntlCalendar::fieldDifference(float $when, int $field): int|false
public IntlCalendar::get(int $field): int
public IntlCalendar::getActualMaximum(int $field): int|false
public IntlCalendar::getActualMinimum(int $field): int|false
public static IntlCalendar::getAvailableLocales(): array
public IntlCalendar::getDayOfWeekType(int $dayOfWeek): int|false
public IntlCalendar::getGreatestMinimum(int $field): int|false
public static IntlCalendar::getKeywordValuesForLocale(string $key, string $locale, bool $commonlyUsed): Iterator|false
public IntlCalendar::getLeastMaximum(int $field): int|false
public IntlCalendar::getLocale(int $localeType): string|false
public IntlCalendar::getMaximum(int $field): int|false
public IntlCalendar::getMinimum(int $field): int|false
public static IntlCalendar::getNow(): float
public IntlCalendar::getTime(): float
public IntlCalendar::getType(): string
public IntlCalendar::getWeekendTransition(string $dayOfWeek): int|false
public IntlCalendar::isSet(int $field): bool
public IntlCalendar::isWeekend(float $date = NULL): bool
public IntlCalendar::roll(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
public IntlCalendar::setFirstDayOfWeek(int $dayOfWeek): bool
public IntlCalendar::setLenient(bool $isLenient): bool
public IntlCalendar::setMinimalDaysInFirstWeek(int $minimalDays): bool
public IntlCalendar::setRepeatedWallTimeOption(int $wallTimeOption): bool
public IntlCalendar::setSkippedWallTimeOption(int $wallTimeOption): bool
public IntlCalendar::setTime(float $date): bool
public IntlCalendar::setTimeZone(mixed $timeZone): bool
}

目录

add a note add a note

User Contributed Notes 1 note

up
1
Julian Sawicki
11 months 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