function month_range($timeZone = 'UTC')
{
$dateTime = new \DateTime('now', new \DateTimeZone($timeZone));
$dateTime->modify('first day of this month');
$start = $dateTime->format('Y-m-d 00:00:00');
$dateTime->modify('last day of this month');
$end = $dateTime->format('Y-m-d 23:59:59');
return [$start, $end];
}
function week_range($timeZone = 'UTC')
{
$dateTime = new \DateTime('now', new \DateTimeZone($timeZone));
$dateTime->modify('Monday this week');
$start = $dateTime->format('Y-m-d 00:00:00');
$dateTime->modify('Sunday this week');
$end = $dateTime->format('Y-m-d 23:59:59');
return [$start, $end];
}
function year_week_range($year, $week, $timeZone = 'UTC')
{
$dateTime = new \DateTime('now', new \DateTimeZone($timeZone));
$dateTime->setISODate($year, $week);
$dateTime->modify('Monday this week');
$start = $dateTime->format('Y-m-d 00:00:00');
$dateTime->modify('Sunday this week');
$end = $dateTime->format('Y-m-d 23:59:59');
return [$start, $end];
}
网友评论