note 85520 deleted from function.strtotime by googleguy

From: Date: Tue, 22 Oct 2013 08:02:47 +0000
Subject: note 85520 deleted from function.strtotime by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196761@lists.php.net to get a copy of this message
Note Submitter: pistachio ---- Note that in some builds of PHP 5 doing the following may return unexpected results: <?php $server_date = date("Y-m-d"); // Assumed GMT 0 $timezone_offset = -10; // GMT -10 $date = date("Y-m-d", strtotime($server_date . " +" . $timezone_offset . " hours")); echo $date; // prints 1969-12-31 ?> What it boils down to is the strtotime function accepting the time offset "+-10 hours", which confuses the function. To be safe be sure to check signs for offset values, and only add the plus (+) sign for non-negative offsets.

« previous php.notes (#196761) next »