note 61278 added to function.mktime
| From: | xangelusx at hotmail dot com | Date: | Mon, 30 Jan 2006 05:36:01 +0000 |
| Subject: | note 61278 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102707@lists.php.net to get a copy of this message | ||
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));
?>
----
Server IP: 64.71.164.2
Probable Submitter: 70.22.183.244
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61278
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61278&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61278&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61278&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61278&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61278&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61278&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61278&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61278&report=yes
Search -- http://master.php.net/manage/user-notes.php