常用
//获取UTC格式时间 2019-04-23T10:19:21+08:00
date(DATE_ATOM);
//本日
$today_start_int = strtotime(date('Y-m-d'));
$today_end_int = strtotime("+1 day");
//本周
$week_start_int = strtotime("this week Mon");
$week_end_int = strtotime("this week Sun");
//本月
$month_start_int = strtotime(date('Y-m-01'));
$month_end_int = strtotime(date('Y-m-01')." +1 month");
/*
* 获取前N个月的间隔时间戳
* @param int $i 前N个月,0表示当前月
* @return array $ret
* */
function get_month_arr($i=11){
$ret = [];
for(;$i>=0;$i--){
$month = strtotime("-{$i} month");
$year_month = date('Y-m',$month);
$month_start = (date('Y-m-d',strtotime($year_month)));
$month_end = (date('Y-m-d',strtotime($year_month.' +1 month')));
$ret[] = [$month_start,$month_end];
}
return $ret;
}