note 85252 deleted from function.strtotime by googleguy

From: Date: Tue, 22 Oct 2013 08:02:39 +0000
Subject: note 85252 deleted from function.strtotime by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196758@lists.php.net to get a copy of this message
Note Submitter: php at info-svc dot com ---- "5.1.0 Now issues the E_STRICT and E_NOTICE time zone errors." This little footnote represents a failure mode under common conditions, which is extremely frustrating. For example, this code ALWAYS returns an error on PHP 5: <?php ini_set('error_reporting', E_ALL|E_STRICT); echo strtotime('Sun, 20 Jul 2008 23:34:07 GMT', time()); ?> Notice a standard HTTP-date was specified, so the PHP timezone setting will never affect the value returned by strtotime(). There is no documented workaround, and the suggested methods including date_default_timezone_get will cause the same errors. To make matters worse, those functions don't exist in older versions. Based on my testing, it is necessary to provide PHP with a hard-coded timezone, any timezone at all, to prevent the error. Since the timezone has no affect on the results, I could use 'UTC' or 'America/Detroit' or any other valid string. <?php if (function_exists('date_default_timezone_set')) { date_default_timezone_set('UTC'); } echo strtotime('Sun, 20 Jul 2008 23:34:07 GMT', time()); ?> This is the only solution I have found so far. Enjoy Robert Chapin Chapin Information Services

« previous php.notes (#196758) next »