note 108697 added to function.strtotime

From: Date: Fri, 18 May 2012 05:53:14 +0000
Subject: note 108697 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-188054@lists.php.net to get a copy of this message
'+1 month' feature of strtotime in php 5.3.11 seems to return a bit odd result: <?php $dates = array('2011-01-28', '2011-01-29', '2011-01-30', '2011-01-31', '2011-02-01', '2011-02-02'); foreach ( $dates as $d ) { echo $d, ' => ', date('Y-m-d', strtotime('+1 month', strtotime($d))), "\n"; } ?> results bought on valid thru ---------- ---------- 2011-01-28 => 2011-02-28 2011-01-29 => 2011-03-01 2011-01-30 => 2011-03-02 // <- should be 2011-03-01 2011-01-31 => 2011-03-03 // <- should be 2011-03-01 2011-02-01 => 2011-03-01 2011-02-02 => 2011-03-02 I wanted to use this for checking the last valid day for 'one month pass', and in this case Jan 30 and Jan 31 produce unexpected result (valid longer than Feb 01). Is this a corect action of strtotime('+1 month', ...)? ---- Server IP: 61.195.146.164 Probable Submitter: 123.219.149.225 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/108697 Del: integrated -- https://master.php.net/note/delete/108697/integrated Del: useless -- https://master.php.net/note/delete/108697/useless Del: bad code -- https://master.php.net/note/delete/108697/bad+code Del: spam -- https://master.php.net/note/delete/108697/spam Del: non-english -- https://master.php.net/note/delete/108697/non-english Del: in docs -- https://master.php.net/note/delete/108697/in+docs Del: other reasons-- https://master.php.net/note/delete/108697 Reject -- https://master.php.net/note/reject/108697 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188054) next »