note 32552 added to function.mktime

From: Date: Sat, 31 May 2003 01:15:45 +0000
Subject: note 32552 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-49463@lists.php.net to get a copy of this message
If you're getting 'hour' in 12-hour format, you have to convert it to 24-hour format before you can use this function. The obvious answer would be to add 12 to every hour. But think again, adding 12 won't work. In 24-hour format the clock starts at 0, not 24. Thus after thinking it out you'd end up with something like this: if ( $am_or_pm == 'pm' ) { $hour = $hour == 12 ? $hour : $hour+12; } else { $hour = $hour == 12 ? 0 : $hour; } Hopefully that'll save someone some time at some point.. Good luck, l0rdphi1 ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32552 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32552&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32552&report=yes

« previous php.notes (#49463) next »