note 72452 added to function.gmmktime
| From: | Tom at osu1 dot php dot net | Date: | Fri, 19 Jan 2007 10:05:28 +0000 |
| Subject: | note 72452 added to function.gmmktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121914@lists.php.net to get a copy of this message | ||
I was getting odd results using gmmktime...
I was converting a date/time to a timestamp to get a date/time in the future. Date/time to convert:
Friday 19th of January 2007 10:06:00 PM.
<?php
gmmktime(9, 46, 0, 1 19, 2007);
?>
Returns this timestamp: 1169201160.
When formatted into a GMT date/time it comes out as Friday 19th of January 2007 10:06:00 AM. Notice
it's 12 hours out from the original date/time.
I finally found the reason to be that gmmktime needs a 24 time not 12, should of noticed this since
it doesn't have an am/pm input.
So the correct call would be something like...
<?php
if($date_time_ampm == "PM") $time_hours += 12;
gmmktime($time_hours, 46, 0, 1 19, 2007);
?>
----
Server IP: 83.138.144.80
Probable Submitter: 87.74.132.135
----
Manual Page -- http://www.php.net/manual/en/function.gmmktime.php
Edit -- https://master.php.net/note/edit/72452
Del: integrated -- https://master.php.net/note/delete/72452/integrated
Del: useless -- https://master.php.net/note/delete/72452/useless
Del: bad code -- https://master.php.net/note/delete/72452/bad+code
Del: spam -- https://master.php.net/note/delete/72452/spam
Del: non-english -- https://master.php.net/note/delete/72452/non-english
Del: in docs -- https://master.php.net/note/delete/72452/in+docs
Del: other reasons-- https://master.php.net/note/delete/72452
Reject -- https://master.php.net/note/reject/72452
Search -- https://master.php.net/manage/user-notes.php