Bug #18281 [Com]: strtotime incorrectly evaluates AM/PM

From: Date: Wed, 18 Aug 2010 19:51:17 +0000
Subject: Bug #18281 [Com]: strtotime incorrectly evaluates AM/PM
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153587@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=18281&edit=1 ID: 18281 Comment by: jedinewrepublic at netscape dot net Reported by: mwilmes at avc dot edu Summary: strtotime incorrectly evaluates AM/PM Status: Bogus Type: Bug Package: Date/time related Operating System: Win 2K PHP Version: 4.2.1 Block user comment: N New Comment: I think you jumped the gun, 05:00:00 is correct but the AM / PM was ommitted from the output Previous Comments: ------------------------------------------------------------------------ [2010-08-18 20:55:56] sniper at svencoop dot com NOT BOGUS. sniper@php.net, you missed his point entirely. His code is correct. strotime() doesn't account for the 12 hour format being passed in, that's the issue. The time string returned is passed to date(), which outputs correctly strtotime()'s invalid conversion of the text string. The issue is when a 12 hour format time like 5:00 PM is passed in, it always returns with 5:00 AM. He is obviously using h for the date output, but that's not important what-so- ever. This should be fixed. ------------------------------------------------------------------------ [2002-07-11 15:15:15] sniper@php.net Your script is buggy. Read this manual page a bit more carefully: http://www.php.net/manual/en/function.date.php h - hour, 12-hour format; i.e. "01" to "12" H - hour, 24-hour format; i.e. "00" to "23" ------------------------------------------------------------------------ [2002-07-11 13:39:23] mwilmes at avc dot edu I'm writing a timeclock for work, but have a problem processing 12 hour times: --Script-- <?php $T=array('05:00 PM','05:00PM','5:00 PM','5:00PM'); foreach ($T as $TIME) { echo $TIME.'<br>'; echo strtotime($TIME).'<br>'; echo date("Y-m-d h:i:s",strtotime($TIME)).'<br><br>'; } ?> --Output-- 05:00 PM 1026432000 2002-07-11 05:00:00 05:00PM 1026432000 2002-07-11 05:00:00 5:00 PM 1026432000 2002-07-11 05:00:00 5:00PM 1026432000 2002-07-11 05:00:00 I've compiled PHP 4.2.1 for Apache 2.0.39 with SSLOpen 0.9.7 beta 2. PHP is installed as a module. Is it me or my box? Thanks in advance, Mike Wilmes ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=18281&edit=1

« previous php.bugs (#153587) next »