Req #63776 [Opn->Nab]: strtotime fails with 'at'

From: Date: Wed, 27 Nov 2013 17:17:05 +0000
Subject: Req #63776 [Opn->Nab]: strtotime fails with 'at'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182967@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63776&edit=1 ID: 63776 Updated by: derick@php.net Reported by: matthewcomp at hotmail dot com Summary: strtotime fails with 'at' -Status: Open +Status: Not a bug Type: Feature/Change Request Package: Date/time related Operating System: Linux gator1111.hostgator.com 3. PHP Version: 5.4.9 Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. This is not a bug. strtotime() can not parse *everything* you throw at it. In this case it sees the extra text "at" as a timezone abbreviation. But as it does not know the abbreviation, it gives up. You can see what it does by using date_parse(): derick@whisky:/tmp $ php -r 'var_dump( date_parse( "Nov 19, 2012 at 7:03 PM" ) );' array(13) { 'year' => int(2012) 'month' => int(11) 'day' => int(19) 'hour' => int(19) 'minute' => int(3) 'second' => int(0) 'fraction' => double(0) 'warning_count' => int(0) 'warnings' => array(0) { } 'error_count' => int(1) 'errors' => array(1) { [13] => string(47) "The timezone could not be found in the database" } 'is_localtime' => bool(true) 'zone_type' => int(0) } Previous Comments: ------------------------------------------------------------------------ [2012-12-14 22:53:59] matthewcomp at hotmail dot com Description: ------------ --- From manual page: http://www.php.net/function.strtotime --- Does not work to read a date in the following format: Nov 19, 2012 at 7:03 PM Test script: --------------- <?php $date = "Nov 19, 2012 at 7:03 PM"; if (($timestamp = strtotime($date)) === false) { echo "The string ($date) is bogus"; } else { echo "$date => " . date('l dS \o\f F Y h:i:s A', $timestamp); } ?> Expected result: ---------------- Correctly parse the date, ignoring at, which can commonly appear in dates. Actual result: -------------- Completely unable to parse the date. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63776&edit=1

« previous php.bugs (#182967) next »