note 61278 deleted from function.mktime by bjori
| From: | bjori@php.net | Date: | Thu, 01 Jun 2006 18:39:26 +0000 |
| Subject: | note 61278 deleted from function.mktime by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-112810@lists.php.net to get a copy of this message | ||
Note Submitter: xangelusx at hotmail dot com
----
As thomas is at xenocast pointed out below, the alternate mktime function from rickenmeer at hotmail
dot com appears to suffers from an odd quirk:
For the months of Jan, Feb, Mar, Apr, Oct, Nov and Dec, the returned timestamp will be off by 5
hours.
For the other months (May, Jun, Jul, Aug and Sep) the returned timestamp will be off by 4 hours.
The reason for this is that his version doesn't account for the difference in hours from GMT
nor for daylight saving time; something that the native mktime function does. I have not tested this
in a time zone other than EST (GMT-5), so the effect could be different if you are elsewhere in the
world. I don't know how mktime decides to adjust for DST, so you might only see one difference
in the time if you are in an area that doesn't use daylight saving time.
In any case, I think the following adjustment would resolve this in most cases:
Change:
<?php
$stamp += $hour * (60 * 60);
?>
To:
<?php
$stamp += $hour * (60 * 60) - (date('Z') + (date('I') * 60 * 60));
?>