PHP bug strtotime

echo date('Y-m',strtotime('-1 months'));
echo "\r\n";
echo date('Y-m',strtotime('first day of last month'));
echo "\r\n";
echo date('Y-m',strtotime('-1 week'));


wKioL1dNOUbj1HINAAAHSdy4nws384.png-wh_50


當遇到月爲31日是 date('Y-m',strtotime('-1 months'));求的月份還是當月的

正確使用方式

echo date('Y-m',strtotime('first day of last month'));


echo date('Y-m-d H:i:s', strtotime('-1 month', strtotime(date('Y-m'))));

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章