php 获取当天,本周的起始日期,当月的起始日期,

//当天0点
$today=date("Ymd",$nowtime);
$today_start=strtotime($today);
//当天 23:59:59
$today_end=strtotime("{$today} + 1 day")-1;

//当月
$month_begindate=date('Y-m-01 H:m:s', strtotime(date("Y-m-d")));

$month_enddate =date('Y-m-d H:m:s', strtotime("$month_begindate +1 month -1 day"));

//转换为时间戳

strtotime($month_begindate);

//本周

$w=date('w',$nowtime); 
//获取本周开始日期,如果$w是0,则表示周日,减去 6 天 
$first=1;
//周一
$week=date('Y-m-d H:i:s',strtotime( date("Ymd")."-".($w ? $w - $first : 6).' days')); 
$week_start=strtotime( date("Ymd")."-".($w ? $w - $first : 6).' days'); 
//本周结束日期 
//周天
$week_end=strtotime("{$week} +1 week")-1;

猜你喜欢

转载自blog.csdn.net/u014724048/article/details/79097152
今日推荐