一小时的差异,但仅限于某些日期

时间:2010-02-10 00:50:31

标签: php date datediff days

为什么在这些日期之间我得到5,9 ....如果我再使用另一年我得到6 ????它只发生在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;
 }
?>

1 个答案:

答案 0 :(得分:3)