note 55839 added to function.strtotime

From: Date: Mon, 15 Aug 2005 06:49:40 +0000
Subject: note 55839 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-93662@lists.php.net to get a copy of this message
When using multiple negative relative items, the result might be a bit unexpected: <?php $basedate = strtotime("15 Aug 2005 10:15:00"); $date1 = strtotime("-1 day 2 hours", $basedate); $date2 = strtotime("-1 day -2 hours", $basedate); echo date("j M Y H:i:s", $date1); // 14 Aug 2005 12:15:00 echo date("j M Y H:i:s", $date2); // 14 Aug 2005 08:15:00 ?> The minus sign has to be added to every relative item, otherwise they are interpreted as positive (increase in time). Other possibility is to use "1 day 2 hours ago". ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55839 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55839&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55839&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55839&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55839&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55839&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55839&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55839&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93662) next »