-1
A
回答
2
参考date_diff。尝试这样的:
$d1 = new DateTime($date1);
$d2 = new DateTime($date2);
$diff = $d2->diff($d1);
echo $diff->days; // 85
0
你可以使用这个如果date_diff,如果你想获得日期1和date2之间或日期不work.Use此功能如果你想在两个给定的日期之间留下剩余的日子,那么你可以增加一个像$ i这样的数字,并且可以返回$ i的值。
function date_range($date1, $date2, $step = '+1 day', $output_format = 'Y-m-d') {
$dates = array();
$current = strtotime($first);
$last = strtotime($last);
$i=1;
while($current <= $last) {
$dates[] = date($output_format, $current);
$dateq = date($output_format, $current);
$current = strtotime($step, $current);
$i++;
}
//return $dates; if u want the dates
return $i; //if u want the count of dates between the tow given dates
}
希望这有助于你..
相关问题
- 1. 计算剩余天数
- 2. 计算剩余天数
- 3. 计算剩余天数
- 4. 如何计算剩余天数?
- 5. 如何用php和mysql计算剩余的剩余时间?
- 6. 计算剩余天数的生日?
- 7. 计数剩余天数
- 8. php从数据库计算剩余天数
- 9. 计算在SQL Server中剩余使用的天数
- 10. 如何计算另一日期的剩余天数
- 11. PHP当天剩余时间
- 12. 如何计算剩余使用次数URLFetch?
- 13. 日期计数器 - 剩余X天
- 14. 的剩余天
- 15. Android计算剩余时间
- 16. Filemaker - 计算剩余假期
- 17. SocialEngine 4计算成员剩余的天数
- 18. 计算一个月中的剩余天数
- 19. 程序,接受一个整数值与计算剩余天
- 20. 在java中剩余天数
- 21. 使用mysql计算从特定日期起一年中剩余的天数
- 22. 如何计算倒计数场景中的剩余时间
- 23. 如何计算出两年之间的日期和剩余天数
- 24. PHP:如何计算剩余时间以分钟为单位?
- 25. 用这个计算剩余时间?
- 26. 如何使用TFS REST API获得剩余迭代天数
- 27. 如何根据剩余天数自动计算开始和结束日期计算?
- 28. 计算用户输入的两个日期之间的剩余天数
- 29. 原型JS - 计算剩余宽度
- 30. 计算剩余下载时间
有几十个类似的问题在左右。最初,从php.net手册中尝试自己,然后在遇到问题时查看此SO论坛。最后在你无法提问时提出问题。 – Thamilan
'http:// php.net/manual/en/function.date-diff.php'这将有助于 – devpro
您能告诉我们您尝试过什么吗? – Jerodev