note 78167 added to function.strtotime

From: Date: Mon, 01 Oct 2007 20:36:14 +0000
Subject: note 78167 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-130965@lists.php.net to get a copy of this message
Some surprisingly wrong results (php 5.2.0): date and time seem not coherent: <?php // Date: Default timezone Europe/Berlin (which is CET) // date.timezone no value $basedate = strtotime("31 Dec 2007 23:59:59"); $date1 = strtotime("-3 months", $basedate); echo date("j M Y H:i:s", $date1); // 1 Oct 2007 23:59:59 WRONG $basedate = strtotime("31 Dec 2007 23:59:59 CET"); $date1 = strtotime("-3 months", $basedate); echo date("j M Y H:i:s", $date1); // 1 Oct 2007 23:59:59 WRONG $basedate = strtotime("31 Dec 2007 23:59:59 GMT"); $date1 = strtotime("-3 months", $basedate); echo date("j M Y H:i:s", $date1); // 1 Oct 2007 00:59:59 CORRECT $basedate = strtotime("31 Dec 2007 22:59:59 GMT"); $date1 = strtotime("-3 months", $basedate); echo date("j M Y H:i:s", $date1); // 1 Oct 2007 23:59:59 WRONG AGAIN $basedate = strtotime("31 Dec 2007 00:00:00 GMT"); $date1 = strtotime("-3 months", $basedate); echo date("j M Y H:i:s", $date1); // 1 Oct 2007 01:00:00 CORRECT $basedate = strtotime("31 Dec 2007 00:00:00 CET"); $date1 = strtotime("-3 months", $basedate); echo date("j M Y H:i:s", $date1); // 1 Oct 2007 00:00:00 WRONG AGAIN $basedate = strtotime("31 Dec 2007 00:00:01"); $date1 = strtotime("-3 months", $basedate); echo date("j M Y H:i:s", $date1); // 1 Oct 2007 00:00:01 WRONG AGAIN ?> ---- Server IP: 194.153.94.10 Probable Submitter: 83.77.35.238 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/78167 Del: integrated -- https://master.php.net/note/delete/78167/integrated Del: useless -- https://master.php.net/note/delete/78167/useless Del: bad code -- https://master.php.net/note/delete/78167/bad+code Del: spam -- https://master.php.net/note/delete/78167/spam Del: non-english -- https://master.php.net/note/delete/78167/non-english Del: in docs -- https://master.php.net/note/delete/78167/in+docs Del: other reasons-- https://master.php.net/note/delete/78167 Reject -- https://master.php.net/note/reject/78167 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130965) next »