-4
如何计算分钟差为2倍的值: -如何计算两个时间之间的时间差
strtotime("-15 minutes");
strtotime("now");
我已经下面的代码中使用: -
$diff = floor(strtotime("now") - strtotime("-15 minutes")/3600);
但它给5天的差异。 请指导我,我错了。
如何计算分钟差为2倍的值: -如何计算两个时间之间的时间差
strtotime("-15 minutes");
strtotime("now");
我已经下面的代码中使用: -
$diff = floor(strtotime("now") - strtotime("-15 minutes")/3600);
但它给5天的差异。 请指导我,我错了。
首先,您将获得小时差分与3600分区。15分钟评估为0时,地板。你也只是将第二个变量与第一个变量分开,而不是第一个变量。 这应该工作:
$diff=floor((strtotime("now") - strtotime("-15 minutes"))/60);
echo $diff;// outputs 15
和额外的括号,否则它将-15分钟除以60 – putvande
你能分享一些代码,所以我们可以帮助吗? –
试试这个 http://stackoverflow.com/questions/21404551/return-the-difference-between-two-dates-and-time-php/21404759#21404759 –
不应该只是是'$差异= ((strtotime(“now”) - strtotime(“ - 15分钟”))/ 60)'? (你错过了方括号,你分开了3600而不是60) – putvande