The IntlGregorianCalendar class
(PHP 5 >= 5.5.0, PHP 7, PHP 8)
简介
类摘要
/* 继承的常量 */
    
    /* 方法 */
    
public __construct(
int
int
int
int
int
int
)
    
int
$timeZoneOrYear,int
$localeOrMonth,int
$dayOfMonth,int
$hour,int
$minute,int
$second = ?)
public static createFromDateTime(
int
int
int
int
int
?int
): static
    int
$year,int
$month,int
$dayOfMonth,int
$hour,int
$minute,?int
$second = null): static
/* 继承的方法 */
    
public static IntlCalendar::createInstance(IntlTimeZone|DateTimeZone|string|null 
$timezone = null, ?string $locale = null): ?IntlCalendarpublic static IntlCalendar::fromDateTime(DateTime|string 
$datetime, ?string $locale = null): ?IntlCalendarpublic static IntlCalendar::getKeywordValuesForLocale(string 
$keyword, string $locale, bool $onlyCommon): IntlIterator|falsepublic IntlCalendar::set(
int
int
int
int
int
int
): true
   }int
$year,int
$month,int
$dayOfMonth = NULL,int
$hour = NULL,int
$minute = NULL,int
$second = NULL): true
目录
- IntlGregorianCalendar::__construct — Create the Gregorian Calendar class
- IntlGregorianCalendar::createFromDate — Create a new IntlGregorianCalendar instance from date
- IntlGregorianCalendar::createFromDateTime — Create a new IntlGregorianCalendar instance from date and time
- IntlGregorianCalendar::getGregorianChange — Get the Gregorian Calendar change date
- IntlGregorianCalendar::isLeapYear — Determine if the given year is a leap year
- IntlGregorianCalendar::setGregorianChange — Set the Gregorian Calendar the change date
  +添加备注
  
用户贡献的备注 1 note
  
  
  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备份地址:http://www.lvesu.com/blog/php/class.intlgregoriancalendar.php