以下是获取今日、昨日、上周、本月起始时间戳和结束时间戳的方法:
获取今日起始时间戳和结束时间戳:
$today_start = strtotime('today');
$today_end = strtotime('tomorrow') - 1;
获取昨日起始时间戳和结束时间戳:
$yesterday_start = strtotime('yesterday');
$yesterday_end = strtotime('today') - 1;
获取上周起始时间戳和结束时间戳:
$last_week_start = strtotime('last week');
$last_week_end = strtotime('last week +6 days') + 86399;
获取本月起始时间戳和结束时间戳:
$this_month_start = strtotime('first day of this month');
$this_month_end = strtotime('last day of this month') + 86399;
注意:以上方法中,起始时间戳是指当天的 00:00:00 的时间戳,结束时间戳是指当天的 23:59:59 的时间戳。
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站