php 获取今天,本周,本月,三个月内,半年内,今年的开始和结束时间
$now = time();
//今天
$today_audit_num = 0;
$today_use_num = 0;
$beginTime = date(‘Y-m-d 00:00:00‘, $now);
$endTime = date(‘Y-m-d 23:59:59‘, $now);
//本周
$week_audit_num = 0;
$week_use_num = 0;
$time = ‘1‘ == date(‘w‘) ? strtotime(‘Monday‘, $now) : strtotime(‘last Monday‘, $now);
$beginTime = date(‘Y-m-d 00:00:00‘, $time);
$endTime = date(‘Y-m-d 23:59:59‘, strtotime(‘Sunday‘, $now));
//本月
$month_audit_num = 0;
$month_use_num = 0;
$beginTime = date(‘Y-m-d 00:00:00‘, mktime(0, 0, 0, date(‘m‘, $now), ‘1‘, date(‘Y‘, $now)));
$endTime = date(‘Y-m-d 23:39:59‘, mktime(0, 0, 0, date(‘m‘, $now), date(‘t‘, $now), date(‘Y‘, $now)));
//三个月内
$three_month_audit_num = 0;
$three_month_use_num = 0;
$time = strtotime(‘-2 month‘, $now);
$beginTime = date(‘Y-m-d 00:00:00‘, mktime(0, 0,0, date(‘m‘, $time), 1, date(‘Y‘, $time)));
$endTime = date(‘Y-m-d 23:39:59‘, mktime(0, 0, 0, date(‘m‘, $now), date(‘t‘, $now), date(‘Y‘, $now))); ;
//半年内
$half_year_audit_num = 0;
$half_year_use_num = 0;
$time = strtotime(‘-5 month‘, $now);
$beginTime = date(‘Y-m-d 00:00:00‘, mktime(0, 0,0, date(‘m‘, $time), 1, date(‘Y‘, $time)));
$endTime = date(‘Y-m-d 23:39:59‘, mktime(0, 0, 0, date(‘m‘, $now), date(‘t‘, $now), date(‘Y‘, $now)));
//今年
$year_audit_num = 0;
$year_use_num = 0;
$beginTime = date(‘Y-m-d 00:00:00‘, mktime(0, 0,0, 1, 1, date(‘Y‘, $now)));
$endTime = date(‘Y-m-d 23:39:59‘, mktime(0, 0, 0, 12, 31, date(‘Y‘, $now)));
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。