|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13880 date(I) does not correctly identify daylight saving time
Submitted: 2001-10-30 19:25 UTC Modified: 2001-11-01 01:34 UTC
From: bmplummer1 at home dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.0.6 OS: Windows NT/XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
26 + 43 = ?
Subscribe to this entry?

 [2001-10-30 19:25 UTC] bmplummer1 at home dot com
There appears to be a bug in the date() function when using the I (capital i) format.  Date(I) always returns 0 (zero) no matter what the date is.  Date(I) is used to determin if a date occurs during daylight saving time or not.  Here is the script I am using:

if (date(I, mktime(0,0,0,6,1,2001))=1) {
    do this;
} else {
    do that;

No mater what the date is it always returns zero.  I have tried setting date(I) to a variable outside of the if/then statement but it always sets the variable to zero.  I have tried setting the timestamp to a variable first and using it in date():

$ts = mktime(0,0,0,6,1,2001);
$ds = date(I, $ts);

That doesn't work either, returns zero. No matter what I do it just doesn't work.  Does this part of date() even work?

Running PHP 4.05 with Zend Optimizer v1.1.0 on Windows NT 4.0 build 1381, CGI version, Apache/1.3.20 .  Also doesn't work on PHP 4.06 on Windows XP, CGI version, Apache/1.3.22.

Thank you for your consideration and hard work.  PHP is a great product.  Keep up the good work!

Bradford Plummer


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-30 19:33 UTC]
Two obvious problems with your test script.

I should be in quotes, and = should be ==.  Make those changes and try again.

This works okay on Linux.

 [2001-10-30 19:36 UTC]
Works on Windows XP as well with 4.0.6.

 [2001-10-30 19:36 UTC]
Works on Windows XP as well with 4.0.6.

 [2001-11-01 01:34 UTC] bmplummer1 at home dot com
cnewbill said this:

Two obvious problems with your test script.
I should be in quotes, and = should be ==.  Make those changes and try again.
This works okay on Linux.


First of all...
You are right.  I left the quotes out of my bug report.  I was, however, using them in the actual script.  If you tested my script you may have also noticed that the following commands return a zero on a Win32 system when they should return a one:

echo date("I", mktime(0,0,0,5,1,2001));
echo date("I", mktime(0,0,0,6,1,2001));
echo date("I", mktime(0,0,0,7,1,2001));
echo date("I", mktime(0,0,0,8,1,2001));
echo date("I", mktime(0,0,0,9,1,2001));
echo date("I", mktime(0,0,0,10,1,2001));

  Also returning a zero instead of a one are:

echo date("I", mktime(0,0,0,date("m")-1,date("d"),  date("Y")));
echo date("I", mktime(0,0,0,date("m")-2,date("d"),  date("Y")));
echo date("I", mktime(0,0,0,date("m")-3,date("d"),  date("Y")));
echo date("I", mktime(0,0,0,date("m")-4,date("d"),  date("Y")));
echo date("I", mktime(0,0,0,date("m")-5,date("d"),  date("Y")));
echo date("I", mktime(0,0,0,date("m")-6,date("d"),  date("Y")));
echo date("I", mktime(0,0,0,date("m")-7,date("d"),  date("Y")));

    So it doesn't seem to matter how I format the original if/then statement because it will always evaluate incorrectly because date() is doing something screwy on Win32.  Also, I found something else while working on this.  When using the M format, date() has a problem figuring out what month name it is supposed to return.  Here is some example script:

echo date("M, I", mktime(0,0,0,date("m")-1,date("d"),  date("Y")));
echo "<br>";
echo date("M, I", mktime(0,0,0,date("m")-2,date("d"),  date("Y")));
echo "<br>";
echo date("M, I", mktime(0,0,0,date("m")-3,date("d"),  date("Y")));
echo "<br>";
echo date("M, I", mktime(0,0,0,date("m")-4,date("d"),  date("Y")));
echo "<br>";
echo date("M, I", mktime(0,0,0,date("m")-5,date("d"),  date("Y")));
echo "<br>";
echo date("M, I", mktime(0,0,0,date("m")-6,date("d"),  date("Y")));
echo "<br>";
echo date("M, I", mktime(0,0,0,date("m")-7,date("d"),  date("Y")));

      That script returns this on my Win32 system:

Oct, 0
Aug, 0
Jul, 0
Jul, 0
May, 0
May, 0
Mar, 0

      At least it did for my yesterday (31 Oct 2001).  Notice how Jul and May are doubled?  What happened to Apr and Jun?

Could you check in to these issues and let me know what you find out.  By the way, thank you for responding so quickly.
Bradford Plummer
 [2011-11-04 16:30 UTC] colin dot mutter at gmail dot com
Bradford, yes it's been 10 years, but I thought I should not leave this question 

If you ran your test on the 31st (as you mentioned), but just subtracted "1" from 
the month, you would have a date like "2001-06-31";  There is no such date, thus 
PHP rounds to a real date:

echo date("Y-m-d", strtotime("2001-06-31"));
// => 2001-07-01
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 20:01:31 2024 UTC