PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #9878 gmmktime is 1 hour off during standard time
Submitted:20 Mar 2001 2:08pm UTC Modified: 7 Nov 2001 9:22am UTC
From:bfoddy at mn dot mediaone dot net Assigned to:
Status:Closed Category:Date/time related
Version:4.0.4pl1 OS:Solaris 2.6
View/Vote Developer Edit Submission

[20 Mar 2001 2:08pm UTC] bfoddy at mn dot mediaone dot net
gmmktime is producing a timestamp 1 hour off when the timezone is
standard time.  If you compare a 
time() with gmmktime  with current settings and a is_dst
value NULL, the results will be one hour off.

I used the following little script to prove this:
<?
print ("<PRE>");
print ("Time function = ".time ());
print ("\n");
print ("gmmktime = ".gmmktime (18,25,0,3,20,2001));
print ("\n");
print ("mktime = ".mktime(12,25,0,3,20,2001));
print ("\n");
print (gmmktime(7,0,0,4,1,2001)."  ".mktime(1,0,0,4,1,2001)."\n");
print (gmmktime(8,0,0,4,1,2001)."  ".mktime(3,0,0,4,1,2001)."\n");

?>

Currently, the US/Central timezone is -6 hours from GMT.

I believe the problem is in ext/standard/datetime.c, line
186.  Judging from the code, "timezone" seems to be a negative seconds
value from GMT, probably of the standard timezone (TZ in standard).  So
if is_dst == 0, you don't want to add anything more.  I think the like
should say:

gmadjust = -(is_dst ? timezone - 3600 : timezone );

And the comment about overcorrecting removed.

My test script works if this line is changed.
[30 Mar 2001 10:13am UTC] bfoddy at mn dot mediaone dot net
I know there are a lot of open bugs and this one is probably pretty
small compared to most, but the time window to
easily verify this bug and my suggested fix is quickly going
away for 6 months.  With the time shift this weekend, it
wil be much more difficult to reproduce this bug, unless you
start subtracting 86400 seconds per day to get back into standard time.

If someone could just look at what I've provided I think
it will be a no-brainer.  Even if it doesn't get tagged into
the new release, at least it will saved for the next.

Thanks
[5 May 2001 3:40pm UTC] rasmus@php.net
Are you sure that bit of code applies in your case?  ie. is
HAVE_TM_GMTOFF undefined in your main/php_config.h file?  I am unable to
recreate this problem here, but on my Linux box my gmadjust value comes
straight from the libc system call ie. I have HAVE_TM_GMTOFF defined.
[7 May 2001 12:52pm UTC] derick@php.net
Waiting for feedback on Rasmus' question.
[7 May 2001 2:10pm UTC] bfoddy at mn dot mediaone dot net
Sorry, I replied to the email, but it didn't get logged to
the record.

Yes I'm sure Solaris2.6 does not have the tm_gmtoff value in 
tm struct.  Linux does, perhaps newer Solaris do also, I
don't know.  But definately 2.6 does not have the value
so the config does not set the HAVE_TM_GMTOF defined.

I supposed to test on Linux you could rebuild php and
override this define.

If its any help, we are using the patch I suggested on a
production Solaris server and it worked fine on both
sides of the time shift in April.
[13 Jul 2001 10:50am UTC] bfoddy at mn dot mediaone dot net
Can we try to get this patch in 4.0.7?  Its not as critical
an issue during the summer, but the standard time will
be here before you know it.
[21 Oct 2001 9:07pm UTC] sniper@php.net
Missing status.
[7 Nov 2001 9:22am UTC] jmoore@php.net
Fixed in CVS
[18 Jan 2002 3:29pm UTC] bfoddy at mn dot mediaone dot net
This fix did NOT get into 4.1.1 as advertised;  I just
checked the 4.1.1 source I downloaded.
Can someone double check
how it was missed and if its in the CVS for the next
release?  Otherwise I can reopen it.

Thanks,
Brian

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC