Description:
------------
the newest 5.1.X version of PHP does not seem to work with day light savings time. the Expected result was recieved from PHP 5.0.4
I am adding 6 days to Oct 25th to cross over daylight savings time on Oct 30th. There should be 25 hours in Oct 30th.
Reproduce code:
---------------
$date = strtotime('25 Oct');
echo date('m/d/Y H:m:s', $date+(86400*6));
Expected result:
----------------
10/30/2005 23:10:00
Actual result:
--------------
10/31/2005 00:10:00

Actually I realize 86400*6 should not be right as my code displays below. It should give you back one hour short, however when I do add 86400*6 onto the day in PHP 5.1.X I am getting the exact 6 days out. That would be a problem. Again PHP 5.0.4 handles this correctly.

I have upgraded to the newest snap as you have requested and I am still getting the same results. PHP 5.0.4 returns the correct time. PHP 5.1.X returns the wrong time. Could this be an operating system issue? I am on Windows XP with Apache 2.

well the problem comes when you cross the daylight savings time day of Oct 30th. Strtotime will handle the 25 hour day just great. Remebering there are 25 hours in Oct 30th is important. That is why when you run the following code in PHP 5.0.4
echo date('r', (strtotime('oct 25')+(86400*6)));
you do get (which is right):
Sun, 30 Oct 2005 23:00:00 -0600
an hour short of Oct 31st. However when you run that code in PHP 5.1.X you find that Oct 30th does not contain 25 hours.
Mon, 31 Oct 2005 00:00:00 +0000
This difference will definitely screw up scripts that are particularly time sensitive, like my field of Travel.

Look at the formatted date:
Mon, 31 Oct 2005 00:00:00 +0000
It doesn't have a timezone offset, so it seems that "xczimi" is right. Does it help if you add:
date_default_timezone_set("America/New_York") at the top of the script?

[2005-08-04 16:44 UTC] jeremy at techtrav dot com

Oh now I understand Czimi comment. If PHP 5.1.X is not looking at the time zone on my XP box then it is not going to know that Oct 30th is daylight savings time. I think Czimi is probably right, PHP 5.1.X is not looking at the time zone my my XP box.

[2005-08-04 16:51 UTC] jeremy at techtrav dot com

I tried adding that line to the top of my code. I am not familar with that function nor do I find it in the documentation. I get a fatal error:
Fatal error: Call to undefined function date_default_timezone_set()
when I run this script:
date_default_timezone_set("America/New_York");
echo date('r', (strtotime('oct 25')+(86400*6)));
I would agree with you in your conclusion though that it would appear that PHP 5.1.X is not reading the timezone of the local machine.

Now, if we can find a way how PHP can guess the correct timezone from your windows box (like it can do on most unices) that would be nice - but I think it's quite impossible.
BTW, if you use error_reporting(E_ALL) you'd have gotten a warning about this...

That function is only there in the snapshots, please try that instead. http://snaps.php.net (and pick latest cvs (5.1-dev) there).

[2005-08-04 16:55 UTC] jeremy at techtrav dot com

okay I figured out how to set my time zone.
I ran the following code in PHP 5.0.4 and PHP 5.1.X and recieved the same result
putenv("TZ=US/Central");
echo date('r', (strtotime('oct 25')+(86400*6)));
This would mean the bug is simply that PHP5.1.X is not looking at the time zone on the local machine.

[2005-08-04 17:01 UTC] jeremy at techtrav dot com

By the way I do have E_ALL turned on, on my machine. After all I don't run my windows box with PHP in production. I use my windows box for development. Our PHP production runs on OpenBSD servers.
I don't quite understand this comment of yours:
"Now, if we can find a way how PHP can guess the correct timezone from your windows box "
PHP 5.0.4 reads my TZ perfectly and gives you the expected result. Why would PHP 5.1.X not be able to?

hi
it seems that I have a related problem:
I am on GMT+1
for the following example the system time is 11:00
date("H:i");
=> 09:00
set system time-zone to GMT(+0)
date("H:i");
=> 09:00
set system time to 10:00
date("H:i");
=> 08:00
It seems that php don't have the correct timezone. This error occurs since 5.1.0b3.
My box runs on win2000SP4 with the latest snapshot.

to derick:
actually its not that difficult to guess the timezone on windows (with the comming winfx api will be even easier).
After some research on the web and some testing:
#include <time.h>
main () {
time_t t;
localtime ((time(&t), &t)); // fill the _tzname var
printf("TZ=%s TZDST=%s\n", _tzname[0], _tzname[1]);
}
with GMT outputs:
TZ=GMTST TZDST=GMTDT
_tzname[0] is the timezone abbr name. _tzname[1] is filled if the current timezone has DST changes.
more testing:
Pacific time:
TZ=PST TZDST=PDT
Central time:
TZ=CST TZDST=CDT
Brasilia:
TZ=ESAST TZDST=ESADT
Brisbane:
TZ=EAST TZDST=
The problem here is that our DB doesn't have these abbreviations. But with some trialing we could all tz settings that windows uses and link them to the main db.

This is datas from your system (or the version you use). The problem with windows is that there is many different datas in each single product version.
--Pierre

[2005-08-13 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".