有没有办法找到PHP的月份差异?我有从2003-10-17到2004-03-24的输入.我需要找到这两天内有多少个月.比如说6个月,我只需要几个月的输出.感谢您指导我一天的差异.
我通过MySQL找到了解决方案,但我需要在PHP中使用它.有人帮助我,提前谢谢.
所以我使用这种方法来获得2个日期之间的差异.
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
Run Code Online (Sandbox Code Playgroud)
现在,让我们说我希望将年份和月份转换为数天.我怎么做?