取某年的最后一天的日期


    $year = "2023-01-01";
    $time = strtotime($year);
    $yearLastDay = date("Y-m-d", strtotime("-1 day", strtotime("+1 year", $time)));

取某个月的最后一天


$month = "2023-01-01";
$time = strtotime($month);
$monthLastDay = date("Y-m-d", strtotime("-1 day", strtotime("+1 month", $time)));

取周的第一天与最后一天、下周的第一天


$week = "2023-04-26";
$time = strtotime($week);
// 第一天
$weekStartDay = date("Y-m-d", strtotime('this week', $time));
// 最后一天
$weekLastDay = date("Y-m-d", strtotime('+6 day', strtotime($weekStartDay)));
// 取下周的第一天
$nextWeekStartDay = date("Y-m-d", strtotime('next week', $time));
说点什么
支持Markdown语法
好耶,沙发还空着ヾ(≧▽≦*)o
Loading...