【发布时间】:2010-02-10 00:50:31
【问题描述】:
为什么在这些日期之间我得到 5,9.... 而如果我再使用一年,我得到 6 ????它只发生在 2008 年 3 月和 2008 年......为什么会有一个小时的差异???
<?php
$from = '2008-03-04';
$to = '2008-03-10';
echo datediff($from,$to);
$from = '2010-03-04';
$to = '2010-03-10';
echo datediff($from,$to);
function datediff($from,$to)
{
$diff = strtotime($to) - strtotime($from);
$diff = $diff/(60*60*24);
return $diff;
}
?>
【问题讨论】:
-
我的猜测是 PHP,考虑到这是我所知道的唯一通用语言
strtotime作为标准。库函数。