Adding years to a date resets to 1970-01-01

后端 未结 5 1055
悲&欢浪女
悲&欢浪女 2020-12-11 09:47
$somedate = \"1980-02-15\";
$otherdate = strtotime(\'+1 year\', strtotime($somedate));
echo date(\'Y-m-d\', $otherdate);

outputs

19         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 10:51

    75 years from 1980 is 2055, which is past the highest date value that can be represented in a 32-bit integer. Therefore the result becomes 0, which is the 1970 date you observe.

提交回复
热议问题