PHP - 总天数不是整数 [英] PHP - total number of days is not an integer
本文介绍了PHP - 总天数不是整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个问题中接受的答案是:计算工作日是错误的。只需检查
The accepted answer in this question: Calculate business days is buggy. Just check
echo getWorkingDays("2012-01-01","2012-05-01",$holidays);
问题出在这个片段:
$days = ($endDate - $startDate) / 86400 + 1;
所以最小的不起作用的例子是:
So the minimal not working example is:
为什么这个表达式:
($endDate - $startDate) / (60*60*24);
不是一个整数:
$startDate = strtotime("2012-01-01");
$endDate = strtotime("2012-05-01");
推荐答案
您已经超过DST门槛。每当你这样做,你的持续时间将是(通常)一个小时或更长。如果你想避免这种情况,那么专门用UTC工作。
You've crossed a DST threshold. Whenever you do so your duration will be (usually) one hour shorter or longer. If you wish to avoid this then work exclusively with UTC.
这篇关于PHP - 总天数不是整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文