note 85520 added to function.strtotime

From: Date: Wed, 03 Sep 2008 15:50:47 +0000
Subject: note 85520 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-144116@lists.php.net to get a copy of this message
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. ---- Server IP: 209.41.74.194 Probable Submitter: 70.187.131.212 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/85520 Del: integrated -- https://master.php.net/note/delete/85520/integrated Del: useless -- https://master.php.net/note/delete/85520/useless Del: bad code -- https://master.php.net/note/delete/85520/bad+code Del: spam -- https://master.php.net/note/delete/85520/spam Del: non-english -- https://master.php.net/note/delete/85520/non-english Del: in docs -- https://master.php.net/note/delete/85520/in+docs Del: other reasons-- https://master.php.net/note/delete/85520 Reject -- https://master.php.net/note/reject/85520 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144116) next »