note 86277 deleted from function.strtotime by googleguy

From: Date: Tue, 22 Oct 2013 08:03:05 +0000
Subject: note 86277 deleted from function.strtotime by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196767@lists.php.net to get a copy of this message
Note Submitter: emperorshishire at gmail dot com ---- 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.

« previous php.notes (#196767) next »