PHP 31号取前几个月日期的BUG
2023-05-12416
有些人,只会在特定的时光出现。
就像这个Bug
$now=date("Y-m-d");
$BeginDate=date('Y-m-01', strtotime("$now -3 month"));
$BeginDate=date('Y-m-01', strtotime("$now -4 month"));
31号这天,3个月前和4个月前返回结果一样。
意思是我要取3个月前的1号的日期
和取4个月前的1号的日期
结果是一样的
是PHP自带的strtotime()对于31日求上N个月有问题
解决方案
$now=date("Y-m-01");
所以说有些Bug,也只会出现在特定的时光
就像有些人,只会在特定的时光出现。
上一篇:离线安装nginx + php