php 如何找到两个日期之间的天数差异
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4502832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find the difference in days between two dates
提问by Xeoncross
Possible Duplicate:
How to find number of days between two dates using php
可能的重复:
如何使用 php 查找两个日期之间的天数
If I have two dates - how do I find the real difference in days between two dates? You must take things like leap years and the number of days in each month into account.
如果我有两个日期 - 我如何找到两个日期之间的实际天数差异?您必须考虑闰年和每个月的天数。
How many days are between something like 2010-03-29
and 2009-07-16
?
2010-03-29
和之间有多少天2009-07-16
?
回答by netcoder
回答by dnagirl
回答by THE DOCTOR
Here you go:
干得好:
<?php
$date1 = strtotime("2010-03-29");
$date2 = strtotime("2009-07-16");
$dateDiff = $date1 - $date2;
$fullDays = floor($dateDiff/(60*60*24));
echo "Differernce is $fullDays days";
?>