php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40717 date "01-01-1968" inaccessible via date function
Submitted: 2007-03-04 17:01 UTC Modified: 2007-05-01 01:00 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: manuel dot pinhao at nvisible dot pt Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.2.1 OS: Windows XP SP2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-03-04 17:01 UTC] manuel dot pinhao at nvisible dot pt
Description:
------------
I've found it impossible to access the date "01-01-1968" via date/mktime.

Reproduce code:
---------------
foreach (range(-63158410,-63158390) as $s) {
echo $s.': '.date("d-m-Y H:i:s",$s)."<br>";
}

Expected result:
----------------
-63158410: 31-12-1967 23:59:50
-63158409: 31-12-1967 23:59:51
-63158408: 31-12-1967 23:59:52
-63158407: 31-12-1967 23:59:53
-63158406: 31-12-1967 23:59:54
-63158405: 31-12-1967 23:59:55
-63158404: 31-12-1967 23:59:56
-63158403: 31-12-1967 23:59:57
-63158402: 31-12-1967 23:59:58
-63158401: 31-12-1967 23:59:59
-63158400: 01-01-1968 00:00:00
-63158399: 01-01-1968 00:00:01
-63158398: 01-01-1968 00:00:02
-63158397: 01-01-1968 00:00:03
-63158396: 01-01-1968 00:00:04
-63158395: 01-01-1968 00:00:05
-63158394: 01-01-1968 00:00:06
-63158393: 01-01-1968 00:00:07
-63158392: 01-01-1968 00:00:08
-63158391: 01-01-1968 00:00:09
-63158390: 01-01-1968 00:00:10

Actual result:
--------------
-63158410: 31-12-1967 23:59:50
-63158409: 31-12-1967 23:59:51
-63158408: 31-12-1967 23:59:52
-63158407: 31-12-1967 23:59:53
-63158406: 31-12-1967 23:59:54
-63158405: 31-12-1967 23:59:55
-63158404: 31-12-1967 23:59:56
-63158403: 31-12-1967 23:59:57
-63158402: 31-12-1967 23:59:58
-63158401: 31-12-1967 23:59:59
-63158400: 02-01-1968 00:00:00
-63158399: 02-01-1968 00:00:01
-63158398: 02-01-1968 00:00:02
-63158397: 02-01-1968 00:00:03
-63158396: 02-01-1968 00:00:04
-63158395: 02-01-1968 00:00:05
-63158394: 02-01-1968 00:00:06
-63158393: 02-01-1968 00:00:07
-63158392: 02-01-1968 00:00:08
-63158391: 02-01-1968 00:00:09
-63158390: 02-01-1968 00:00:10

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-04 17:22 UTC] iliaa@php.net
Have you tried setting the timezone to UTC?
 [2007-03-04 17:43 UTC] manuel dot pinhao at nvisible dot pt
I get the same output with this code:

putenv("TZ=UTC");

foreach (range(-63158410,-63158390) as $s) {
	echo $s.': '.date("d-m-Y H:i:s (T)",$s)."<br>";
}
 [2007-03-04 18:17 UTC] iliaa@php.net
Have you tried setting the timezone via the php prescribed function:

date_default_timezone_set() ?
 [2007-03-04 18:36 UTC] manuel dot pinhao at nvisible dot pt
same output with the following code:

date_default_timezone_set("UTC");

foreach (range(-63158410,-63158390) as $s) {
	echo $s.': '.date("d-m-Y H:i:s (T)",$s)."<br>";
}


Shouldn't this work regardless of the timezone? How can we have a 'disappearing' day?
 [2007-03-05 00:11 UTC] iliaa@php.net
The DST offset could move you to the next day, you may want to try to 
pick 6-7 am on the 1st of Jan 1968 to see if that works.
 [2007-03-05 10:03 UTC] derick@php.net
This works fine for me (on Linux):

-63158410: 31-12-1967 23:59:50 (UTC)
-63158409: 31-12-1967 23:59:51 (UTC)
-63158408: 31-12-1967 23:59:52 (UTC)
-63158407: 31-12-1967 23:59:53 (UTC)
-63158406: 31-12-1967 23:59:54 (UTC)
-63158405: 31-12-1967 23:59:55 (UTC)
-63158404: 31-12-1967 23:59:56 (UTC)
-63158403: 31-12-1967 23:59:57 (UTC)
-63158402: 31-12-1967 23:59:58 (UTC)
-63158401: 31-12-1967 23:59:59 (UTC)
-63158400: 01-01-1968 00:00:00 (UTC)
-63158399: 01-01-1968 00:00:01 (UTC)
-63158398: 01-01-1968 00:00:02 (UTC)
-63158397: 01-01-1968 00:00:03 (UTC)
-63158396: 01-01-1968 00:00:04 (UTC)
-63158395: 01-01-1968 00:00:05 (UTC)
-63158394: 01-01-1968 00:00:06 (UTC)
-63158393: 01-01-1968 00:00:07 (UTC)
-63158392: 01-01-1968 00:00:08 (UTC)
-63158391: 01-01-1968 00:00:09 (UTC)
-63158390: 01-01-1968 00:00:10 (UTC)

 [2007-03-05 10:20 UTC] manuel dot pinhao at nvisible dot pt
Yes, this seems to be a windows-only problem. I've tested it on Linux and it works as expected.
Regarding DST, I'm no expert on this matter, but DST could probably 'bump' time one hour forwards or backwards, not lose a whole day. As for testing 6-7 AM, I wasn't able to target any hours in 01-01-1968.
 [2007-03-05 10:35 UTC] derick@php.net
Portugal didn't do DST between 1966 and 1976, so that is not the issue. I'll have to see what I get on Windows once that POS wants to boot again :)
 [2007-03-28 08:47 UTC] derick@php.net
I can't reproduce this on windows (2k) either.
 [2007-04-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-04-09 10:39 UTC] manuel dot pinhao at nvisible dot pt
My setup is Windows XP SP2. This bug should be reproducible in that OS.
 [2007-04-23 14:43 UTC] tijnema at gmail dot com
I've tested this code on Win XP SP2 (PHP-5.2.1/Apache 2.2.3):
<?php
date_default_timezone_set("UTC");

foreach (range(-63158410,-63158390) as $s) {
	echo $s.': '.date("d-m-Y H:i:s (T)",$s)."<br>";
}
?>

And it returns this:
-63158410: 31-12-1967 23:59:50 (UTC)
-63158409: 31-12-1967 23:59:51 (UTC)
-63158408: 31-12-1967 23:59:52 (UTC)
-63158407: 31-12-1967 23:59:53 (UTC)
-63158406: 31-12-1967 23:59:54 (UTC)
-63158405: 31-12-1967 23:59:55 (UTC)
-63158404: 31-12-1967 23:59:56 (UTC)
-63158403: 31-12-1967 23:59:57 (UTC)
-63158402: 31-12-1967 23:59:58 (UTC)
-63158401: 31-12-1967 23:59:59 (UTC)
-63158400: 01-01-1968 00:00:00 (UTC)
-63158399: 01-01-1968 00:00:01 (UTC)
-63158398: 01-01-1968 00:00:02 (UTC)
-63158397: 01-01-1968 00:00:03 (UTC)
-63158396: 01-01-1968 00:00:04 (UTC)
-63158395: 01-01-1968 00:00:05 (UTC)
-63158394: 01-01-1968 00:00:06 (UTC)
-63158393: 01-01-1968 00:00:07 (UTC)
-63158392: 01-01-1968 00:00:08 (UTC)
-63158391: 01-01-1968 00:00:09 (UTC)
-63158390: 01-01-1968 00:00:10 (UTC)

I see no problem...
 [2007-04-23 14:47 UTC] derick@php.net
So still nobody can reproduce it...
 [2007-05-01 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 13:01:29 2024 UTC