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

发布于 2024-08-20 11:52:52 字数 392 浏览 3 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文