donglinxia1541 2017-03-01 17:11 采纳率: 0%
浏览 70
已采纳

这是一个PHP date()错误吗?

Here is my code:

<?php

echo date("Y-m-d H:i:s",1477785600) ;
echo "<br />";
echo date("Y-m-d H:i:s",1477789200) ;

?>

and result is

2016-10-30 02:00:00
2016-10-30 02:00:00

Why does date() get the same result with different timestamps?
Is that a PHP bug?

My environment setting is:

date.timezone=Europe/Berlin PHP Version 5.6.30
  • 写回答

1条回答 默认 最新

  • dongwu8653 2017-03-01 17:24
    关注

    That's the correct output. In Western Europe, on 30 October 2016 it was 2:00 twice due to daylight saving time:

    1. It was first 2:00 CEST (+0200).

    2. One hour later, at 3:00, the clock was reset one hour and it was 2:00 CET (+0100).

    Here's a slightly clearer test case:

    date_default_timezone_set('Europe/Berlin');
    echo date("r",1477785600) . "
    ";
    echo date("r",1477789200) ;
    
    Sun, 30 Oct 2016 02:00:00 +0200
    Sun, 30 Oct 2016 02:00:00 +0100
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波