php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71945 Wrong timecalc prior 1956 -> summertime?
Submitted: 2016-04-01 15:49 UTC Modified: 2016-04-04 14:02 UTC
From: snoopyf at gmx dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: snoopyf at gmx dot net
New email:
PHP Version: OS:

 

 [2016-04-01 15:49 UTC] snoopyf at gmx dot net
Description:
------------
Having this Unix Timestamp:
-433044000

and date.timezone in php.ini is set to "Europe/Berlin" this function:
date("Y-m-d H:i:s");

returns:
1956-04-11 23:00:00

Test script:
---------------
<?php
echo(date_default_timezone_get());
echo(date("Y-m-d H:i:s",-433044000));
?>


Expected result:
----------------
The result should be:

1956-04-12 00:00:00

For me this seems to be summertime - related as 1956 was the current beginnig of summertime changes...

Checking with JavaScript on the same machine gives the correct result:

<script language="JavaScript">
        var d=new Date(-433044000*1000); // *1000 as JavaScripts Date works with milliseconds since epoch, not seconds
        document.write(d);
</script>

This Snippet returns:
Thu Apr 12 1956 00:00:00 GMT+0200 (CET) 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-01 16:01 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2016-04-01 16:01 UTC] derick@php.net
The correct result is "1956-04-11 23:00:00". Germany did not use summer time until 1980:

Europe/Berlin  Sun Apr 10 00:59:59 1949 UT = Sun Apr 10 01:59:59 1949 CET isdst=0 gmtoff=3600
Europe/Berlin  Sun Apr 10 01:00:00 1949 UT = Sun Apr 10 03:00:00 1949 CEST isdst=1 gmtoff=7200
Europe/Berlin  Sun Oct  2 00:59:59 1949 UT = Sun Oct  2 02:59:59 1949 CEST isdst=1 gmtoff=7200
Europe/Berlin  Sun Oct  2 01:00:00 1949 UT = Sun Oct  2 02:00:00 1949 CET isdst=0 gmtoff=3600
Europe/Berlin  Sun Apr  6 00:59:59 1980 UT = Sun Apr  6 01:59:59 1980 CET isdst=0 gmtoff=3600
Europe/Berlin  Sun Apr  6 01:00:00 1980 UT = Sun Apr  6 03:00:00 1980 CEST isdst=1 gmtoff=7200
Europe/Berlin  Sun Sep 28 00:59:59 1980 UT = Sun Sep 28 02:59:59 1980 CEST isdst=1 gmtoff=7200
Europe/Berlin  Sun Sep 28 01:00:00 1980 UT = Sun Sep 28 02:00:00 1980 CET isdst=0 gmtoff=3600
Europe/Berlin  Sun Mar 29 00:59:59 1981 UT = Sun Mar 29 01:59:59 1981 CET isdst=0 gmtoff=3600
Europe/Berlin  Sun Mar 29 01:00:00 1981 UT = Sun Mar 29 03:00:00 1981 CEST isdst=1 gmtoff=7200
Europe/Berlin  Sun Sep 27 00:59:59 1981 UT = Sun Sep 27 02:59:59 1981 CEST isdst=1 gmtoff=7200
Europe/Berlin  Sun Sep 27 01:00:00 1981 UT = Sun Sep 27 02:00:00 1981 CET isdst=0 gmtoff=3600

It outputs the same on the shell as in PHP too:

derick@whisky:~ $ TZ=Europe/Berlin date --date "@-433044000"
Wed 11 Apr 23:00:00 CET 1956


The output in javascript also makes no sense, as "Thu Apr 12 1956 00:00:00 GMT+0200 (CET)" uses "+0200" for CET, but that's really supposed to be CEST.
 [2016-04-01 18:24 UTC] snoopyf at gmx dot net
Yeah, u r right, for Germany summertime is since 1980, getted that wrong.

Then it's JavaScript which makes the mistake in your opinion? Till now I tested the JavaScript Snippet on the current Versions of Firefox and Chrome under Linux and IE11 under Windows... 
Each and every Browser/JavaScript says, that -433044000 is 2016-04-12 00:00:00

So who sais the truth now?
 [2016-04-04 14:02 UTC] derick@php.net
From what I understand Windows doesn't keep track of historical timezone rules, so that could be an issue here. I have just tested the JavaScript snippet too, and I get the wrong result on Linux/Firefox too. PHP (and the shell) definitely get it right.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jun 03 01:01:26 2025 UTC