Re: cvs: /php3/functions datetime.c && notes on gmmktime()
| From: | Jouni Ahto | Date: | Wed, 06 Oct 1999 07:51:51 +0000 |
| Subject: | Re: cvs: /php3/functions datetime.c && notes on gmmktime() | ||
| References: | 1 | Groups: | php.dev php.version4 |
| Request: | Send a blank email to php-version4+get-5225@lists.php.net to get a copy of this message | ||
We've got some heavy problems with gmmktime() and it's
semantics when invoking with different number of parameters.
I've just committed a fix for this to PHP3 cvs which tries
to correct the situation, but I'm a little bit unsure what
the correct behaviour should be. Anyway, some results seem
to be just clearly wrong or don't make any sense to me.
The script I used for testing and results with different
versions of PHP are attached at the end.
Jouni Ahto
The script used for testing:
<?
echo date("M d Y H:i:s", mktime(0,0,0,1,1,1970)) . "\n";
echo gmdate("M d Y H:i:s", mktime(0,0,0,1,1,1970)) . "\n";
echo date("M d Y H:i:s", gmmktime(0,0,0,1,1,1970)) . "\n";
echo gmdate("M d Y H:i:s", gmmktime(0,0,0,1,1,1970)) . "\n\n";
echo date("M d Y H:i:s", mktime(0,0,0)) . "\n";
echo gmdate("M d Y H:i:s", mktime(0,0,0)) . "\n";
echo date("M d Y H:i:s", gmmktime(0,0,0)) . "\n";
echo gmdate("M d Y H:i:s", gmmktime(0,0,0)) . "\n\n";
echo date("M d Y H:i:s", mktime()) . "\n";
echo gmdate("M d Y H:i:s", mktime()) . "\n";
echo date("M d Y H:i:s", gmmktime()) . "\n";
echo gmdate("M d Y H:i:s", gmmktime()) . "\n\n";
echo mktime() . " " . gmmktime() . "\n";
?>
And the results:
Note: in the winter Finland, my timezone, is at GMT+0200,
on daylight savings time, ie. currently, at GMT+0300.
PHP3 behaviour before fix:
Jan 01 1970 00:00:00 OK
Dec 31 1969 22:00:00 OK
Jan 01 1970 00:00:00 Wrong, off by -2 hours
Dec 31 1969 22:00:00 Wrong, off by -2 hours
Oct 06 1999 00:00:00 OK
Oct 05 1999 21:00:00 OK
Oct 06 1999 01:00:00 ?? Doesn't make any sense to me
Oct 05 1999 22:00:00 ?? Doesn't make any sense to me
Oct 06 1999 08:16:28 OK
Oct 06 1999 05:16:28 OK
Oct 06 1999 06:16:28 ?? Doesn't make any sense to me
Oct 06 1999 03:16:28 ?? Doesn't make any sense to me
939186988 939179788 gmmktime() is -2 hours off mktime(), clearly wrong
PHP3 behaviour after fix:
Jan 01 1970 00:00:00 OK
Dec 31 1969 22:00:00 OK
Jan 01 1970 02:00:00 OK
Jan 01 1970 00:00:00 OK
Oct 06 1999 00:00:00 OK
Oct 05 1999 21:00:00 OK
Oct 06 1999 03:00:00 OK if gmmktime(0,0,0) == what local time is at
GMT midnight time today
Oct 06 1999 00:00:00 OK if gmmktime(0,0,0) == what local time is at
GMT midnight time today
Oct 06 1999 08:16:28 OK
Oct 06 1999 05:16:28 OK
Oct 06 1999 11:16:28 ?? Depends on the meaning of gmmktime()
Oct 06 1999 08:16:28 ?? Depends on the meaning of gmmktime()
939186988 939197788 gmmktime() == mktime()-offset_to_gmt, ie. if now
here is Oct 06 1999 08:16:28, what the timestamp
is when it is Oct 06 1999 08:16:28 at GMT (sorry,
I tried a long time to make some sense to this
sentence but couldn't...)
PHP3 behaviour after fix #2:
Jan 01 1970 00:00:00 OK
Dec 31 1969 22:00:00 OK
Jan 01 1970 02:00:00 OK
Jan 01 1970 00:00:00 OK
Oct 06 1999 00:00:00 OK
Oct 05 1999 21:00:00 OK
Oct 06 1999 03:00:00 OK if gmmktime(0,0,0) == what local time is at
GMT midnight time today
Oct 06 1999 00:00:00 OK if gmmktime(0,0,0) == what local time is at
GMT midnight time today
Oct 06 1999 08:16:28 OK
Oct 06 1999 05:16:28 OK
Oct 06 1999 08:16:28 ?? Depends on the meaning of gmmktime()
Oct 06 1999 05:16:28 ?? Depends on the meaning of gmmktime()
939186988 939186988 gmmktime() == mktime() == time
PHP4 current behaviour:
Jan 01 1970 00:00:00 OK
Dec 31 1969 22:00:00 OK
Jan 01 1970 02:00:00 OK
Jan 01 1970 00:00:00 OK
Oct 06 1999 00:00:00 OK
Oct 05 1999 21:00:00 OK
Oct 06 1999 04:00:00 ?? Doesn't make any sense to me
Oct 06 1999 01:00:00 ?? Doesn't make any sense to me
Oct 06 1999 08:16:29 OK
Oct 06 1999 05:16:29 OK
Oct 06 1999 12:16:29 ?? Doesn't make any sense to me
Oct 06 1999 09:16:29 ?? Doesn't make any sense to me
939186989 939201389 gmmktime() is +4 hours off mktime(), clearly wrong