获取一周及其边界的示例(用于构建日历视图)
<?php
$date = new DateTime('now');
$locale = 'en_US';
$thisWeek = IntlCalendar::fromDateTime($date, $locale);
$thisWeek->set(IntlCalendar::FIELD_DAY_OF_WEEK, $thisWeek->getFirstDayOfWeek());
$weekStart = $thisWeek->toDateTime();
$daysToAdvance = $thisWeek->getMaximum(IntlCalendar::FIELD_DAY_OF_WEEK) - 1;
$weekEnd = $weekStart->modify("+{$daysToAdvance} days");
$previousWeek = IntlCalendar::fromDateTime($date, $locale);
$previousWeek->add(IntlCalendar::FIELD_WEEK_OF_YEAR, -1);
$previousWeek = $previousWeek->toDateTime();
$nextWeek = IntlCalendar::fromDateTime($date, $locale);
$nextWeek->add(IntlCalendar::FIELD_WEEK_OF_YEAR, 1);
$nextWeek = $nextWeek->toDateTime();
?>