在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);