note 72847 added to function.strtotime

From: Date: Sat, 03 Feb 2007 05:08:40 +0000
Subject: note 72847 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-122647@lists.php.net to get a copy of this message
Example 432 doesn't escape the letter 'o' in the argument to date(), so the resulting string doesn't look right. <?php $str = "September 7, 1976"; // previous to PHP 5.1.0 you would compare with -1, instead of false if (($timestamp = strtotime($str)) === false) { echo "The string ($str) is bogus"; } else { /* This doesn't work. The date() function interpolates the letter 'o' in 'of' as an "ISO-8601 year number" */ echo "$str == " . date('l dS of F Y h:i:s A', $timestamp); //September 7, 1976 == Tuesday 07th 1976f September 1976 12:00:00 AM /* This works. The letters o and f are escaped with slashes. */ echo "$str == " . date('l dS \o\f F Y h:i:s A', $timestamp); //September 7, 1976 == Tuesday 07th of September 1976 12:00:00 AM } ?> According to the docs for date(), the 'o' character was added in PHP 5.1.0. It may be worthwhile to escape every non-whitespace character in the format string, in case more functionality is added in the future. ---- Server IP: 216.194.113.175 Probable Submitter: 67.140.231.143 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/72847 Del: integrated -- https://master.php.net/note/delete/72847/integrated Del: useless -- https://master.php.net/note/delete/72847/useless Del: bad code -- https://master.php.net/note/delete/72847/bad+code Del: spam -- https://master.php.net/note/delete/72847/spam Del: non-english -- https://master.php.net/note/delete/72847/non-english Del: in docs -- https://master.php.net/note/delete/72847/in+docs Del: other reasons-- https://master.php.net/note/delete/72847 Reject -- https://master.php.net/note/reject/72847 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122647) next »