PHP获取当日或本月时间戳范围

在mysql数据库中使用int类型保存时间戳时,一般在程序中可能会用到统计当日,当月的一些数据。那么可以用如下的方式限定时间范围:
 
//当日销售
$today_start = strtotime(date('Y-m-d 00:00:00'));
$today_end = strtotime(date('Y-m-d 23:59:59'));
 
//本月销售
$month_start = strtotime(date("Y-m-01"));
$month_end = strtotime("+1 month -1 seconds", $month_start);

posted @ 2018-11-17 11:36  阿木工作室  阅读(4353)  评论(0编辑  收藏  举报