note 86277 added to function.strtotime

From: Date: Fri, 10 Oct 2008 16:26:17 +0000
Subject: note 86277 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-145246@lists.php.net to get a copy of this message
Just a quick note on dealing with non-standard strings: If you attempt to parse single, random letters, strtotime() will give you apparently random output. Because strtotime() uses C's get_date() function, all dangling single letters are interpreted as military time zones. So, for example: <?php echo date('r', time())."<br />\n"; echo date('r', strtotime('L'))."<br />\n"; echo date('r', strtotime('1999L')); ?> will return: Fri, 10 Oct 2008 12:12:28 -0400 Thu, 09 Oct 2008 21:12:28 -0400 Sat, 09 Oct 1999 21:12:28 -0400 when executed in the UTC -5 timezone, because "L" is defined as UTC+11. J will return unix epoch, because it is not defined as a military time zone, while \t and \n both return the current time, as does a space. All other single characters return unix epoch, because they are not defined. The returned time is relative to the specified time, so the third example returns the current day and time in the year 1999, in timezone UTC +11. ---- Server IP: 209.41.74.194 Probable Submitter: 130.64.108.123 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/86277 Del: integrated -- https://master.php.net/note/delete/86277/integrated Del: useless -- https://master.php.net/note/delete/86277/useless Del: bad code -- https://master.php.net/note/delete/86277/bad+code Del: spam -- https://master.php.net/note/delete/86277/spam Del: non-english -- https://master.php.net/note/delete/86277/non-english Del: in docs -- https://master.php.net/note/delete/86277/in+docs Del: other reasons-- https://master.php.net/note/delete/86277 Reject -- https://master.php.net/note/reject/86277 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145246) next »