一小时的差异,但只有一些日期 [英] One hour difference, but only for some dates

查看:88
本文介绍了一小时的差异,但只有一些日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在这些日期之间我得到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);

函数datediff($ from,$ to)
{
$ diff = strtotime($ to) - strtotime($ from);
$ diff = $ diff /(60 * 60 * 24);
return $ diff;
}
?>


解决方案

夏令时


Why between those dates I get 5,9.... and if I use another year I get 6 ???? It only happens with March and 2008... why is there an hour difference ???

<?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;
 }
?>

解决方案

Daylight Saving Time.

这篇关于一小时的差异,但只有一些日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆