(PHP 5 >= 5.5.0, PHP 7, PHP 8)
$timeZoneOrYear
,$localeOrMonth
,$dayOfMonth
,$hour
,$minute
,$second
= ?$year
,$month
,$dayOfMonth
,$hour
,$minute
,$second
= null
$timezone
= null
, ? string $locale
= null
): ? IntlCalendar $datetime
, ? string $locale
= null
): ? IntlCalendar $keyword
, string $locale
, bool $onlyCommon
): IntlIterator |false $year
,$month
,$dayOfMonth
= NULL,$hour
= NULL,$minute
= NULL,$second
= NULLI 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