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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM