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];
}
posted @ 2020-03-04 09:47  haha瓜  阅读(342)  评论(0编辑  收藏  举报