php 获取指定周月的起始时间

public static function weekRange($date) {
$ts = strtotime($date);
$start_date = date('Y-m-d', strtotime('last sunday next day', $ts));
$end_date = date('Y-m-d', strtotime('next monday', $ts) - 1);
return [$start_date, $end_date];
}

public static function monthRange($date) {
    $ts = strtotime($date);
    $start_date = date('Y-m-01', $ts);
    $end_date = date('Y-m-d', strtotime("{$start_date} +1 month -1 day"));
    return [$start_date, $end_date];
}
原文地址:https://www.cnblogs.com/hiraeth/p/12407745.html