<?php
//今天
$start=strtotime(date("Y-m-d", time()));
$end= $start + 24 * 3600-1;//获取今日时间
var_dump( "day:");
var_dump( date("Y-m-d H:i:s",$start)." 至 ".date("Y-m-d H:i:s",$end));
//昨天
$start_yesterday=strtotime(date("Y-m-d", strtotime("-1 day")));
$end_yesterday= $start_yesterday + 24 * 3600-1;//获取昨天时间
var_dump( "yesterday:");
var_dump( date("Y-m-d H:i:s",$start_yesterday)." 至 ".date("Y-m-d H:i:s",$end_yesterday));
//这个月
$start_mouth = mktime(0,0,0,date('m'),1,date('y'));
$end_mouth = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
var_dump( "mouth:");
var_dump( date("Y-m-d H:i:s",$start_mouth)." 至 ".date("Y-m-d H:i:s",$end_mouth));
//下个月
$star_lastMoth = mktime(0, 0, 0, date('m') - 1, 1, date('Y'));
$end_lastMoth = mktime(23, 59, 59, date('m') - 1, date('t', $star_lastMoth), date('Y'));
var_dump( "lastMoth:");
var_dump( date("Y-m-d H:i:s",$star_lastMoth)." 至 ".date("Y-m-d H:i:s",$end_lastMoth));
//今年
var_dump( "year:");
var_dump( date("Y-01-01 00:00:00")." 至 ".date("Y-m-d H:i:s",time()));
06-01
334
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)