php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23467 Showing incorrect Time Zone
Submitted: 2003-05-03 12:14 UTC Modified: 2004-02-11 20:22 UTC
Votes:14
Avg. Score:4.5 ± 0.9
Reproduced:13 of 14 (92.9%)
Same Version:10 (76.9%)
Same OS:12 (92.3%)
From: John at JGSystems dot net Assigned:
Status: Closed Package: Date/time related
PHP Version: 4CVS, 5CVS OS: win32
Private report: No CVE-ID:
 [2003-05-03 12:14 UTC] John at JGSystems dot net
Running PHP with BadBlue on Two machines.  One Win2K Pro, the other XP SPK1.  Also on a Linux Apache production machine.

"T" Option to the date function appears to display incorrectly.  Shows Mountain Standard Time all the time.  It is now Daylight Savings Time here in Montana.

Script:

php print "This page was last modified:<br>".date("l - F d, Y \\a\\t g:i A T.", getlastmod())

Under my Apache servers PHP displays correctly.  I use this for the getlastmod() document function.  Here is a copy/paste from the same page on two different servers.

Linux Apache (Production Machine):

This page was last modified:
Friday - April 25, 2003 at 11:30 AM MDT.

Windows 2K/XP:

This page was last modified:
Friday - April 25, 2003 at 11:30 AM Mountain Standard Time. 

This also happens with a simple date printout:

php print "This page was last modified:<br>".date("l - F d, Y \\a\\t g:i A T.")

Saturday - May 03, 2003 at 11:09 AM Mountain Standard Time.

Hope this helps.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-20 20:35 UTC] John at JGSystems dot net
Here ya go:
Commands:
echo date("r"),"<br>\n";
echo date("I"),"<br>\n";  // uppercase "i"
echo date("T"),"<br>\n";

Result:
Wed, 20 Aug 2003 19:33:34 -0600
1
BST

This what you wanted? (I hope)
 [2003-08-26 22:59 UTC] sniper@php.net
This is general win32 problem. No need to post anymore comments here, we know about it.

 [2003-11-04 21:18 UTC] danielc at analysisandsolutions dot com
Um, sorry if I'm cluttering the list...  This bug is half a year old so I'm wondering if/when it's going to get fixed.

Y'all probably know what's going on, but allow me to clarify what I've learned about this bug, perhaps it will help someone.

date('T') doesn't work under Windows during Daylight times and there's no notation of this in the manual.  I'll put a user comment in there.

Here's a test script:

<?php
echo 'Local:     dT='.date('T') . ' dO='.date('O') . ' sZ='.strftime('%Z');

echo "\n<br />";
putenv('TZ=EST5EDT');
echo 'EST5EDT:   dT='.date('T') . ' dO='.date('O') . ' sZ='.strftime('%Z');

echo "\n<br />";
putenv('TZ=PST8PDT');
echo 'PST8PDT:   dT='.date('T') . ' dO='.date('O') . ' sZ='.strftime('%Z');

echo "\n<br />";
putenv('TZ=GMT0BST');
echo 'GMT0BST:   dT='.date('T') . ' dO='.date('O') . ' sZ='.strftime('%Z');

echo "\n<br />";
putenv('TZ=MST-3MDT');
echo 'MST-3MDT:  dT='.date('T') . ' dO='.date('O') . ' sZ='.strftime('%Z');

echo "\n<br />";
putenv('TZ=GMT');
echo 'GMT:       dT='.date('T') . ' dO='.date('O') . ' sZ='.strftime('%Z');
?>


OUTPUT DURING EASTERN DAYLIGHT TIME
-----------------------------------
Local:     dT=BST dO=-0400 sZ=Eastern Daylight Time
EST5EDT:   dT=BST dO=-0400 sZ=EDT
PST8PDT:   dT=BST dO=-0700 sZ=PDT
GMT0BST:   dT=BST dO=+0100 sZ=BST
MST-3MDT:  dT=BST dO=+0400 sZ=MDT
GMT:       dT=GMT dO=+0000 sZ=GMT

OUTPUT DURING EASTERN STANDARD TIME
-----------------------------------
Local:     dT=Eastern Standard Time dO=-0500 sZ=Eastern Standard Time
EST5EDT:   dT=EST dO=-0500 sZ=EST
PST8PDT:   dT=PST dO=-0800 sZ=PST
GMT0BST:   dT=GMT dO=+0000 sZ=GMT
MST-3MDT:  dT=MST dO=+0300 sZ=MST
GMT:       dT=GMT dO=+0000 sZ=GMT
 [2004-02-10 07:26 UTC] scottmacvicar at ntlworld dot com
tname[0] is replaced with tzname[0] if it exists, the same should be done with tname[1] but it doesn't need set to ??? like tname[0] since the default value is BST set in the tname declaration.

I've tested this patch on windows and will try to test on linux.

Patch
---
diff -u datetime.c datetime.c.patched
--- datetime.c  2004-02-10 12:30:17.000000000 +0000
+++ datetime.c.patched  2004-02-10 12:32:12.000000000 +0000
@@ -324,6 +324,10 @@
                } else {
                        tname[0] = "???";
                }
+
+               if (tzname[1] != NULL) {
+                       tname[1] = tzname[1];
+               }
 #endif
        }
 [2004-02-11 20:22 UTC] sniper@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 00:01:21 2014 UTC