$month = date('m', strtotime('-19 years'));
$day = date('d', strtotime('-19 years'));
$year = date('Y', strtotime('-19 years'));这正确地得到了19年前的月/日/年,这一天(2021年1月8日)分别是2002年1月8日。我怎么能做到19年零1天前? 19年零1个月前? 19年零1天零1个月前?等。
对于第一种情况(19年零一天前),$month = date('m', strtotime('-19 years -1day'))不起作用。
发布于 2021-01-10 10:00:05
strtotime()接受第二个参数,它是用于相对时间的基准日期。所以你可以从现在开始减去一天,然后使用-19 years
strtotime('-19 years', strtotime('-1 day'))https://stackoverflow.com/questions/65649487
复制相似问题