note 100988 added to function.strtotime

From: Date: Fri, 19 Nov 2010 04:35:32 +0000
Subject: note 100988 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-174170@lists.php.net to get a copy of this message
I mean... <?php function wdates($start = 0, $amount = 10, $format = 'Y', $interval = 'Y', $decrease = true) { // Determining where we should start the dates (In years) $start = ((is_numeric($start)) ? $start : 0); // Accomidating the AMOUNT returned accordignly to the START $amount += $start; // Creating an array of years {$amount} times for($i = $start; $i < $amount; ++$i) { // Checking the interval to increase/decrease by $int = (($interval == 'D') ? 'day' : (($interval == 'M') ? 'month' : 'year')); // Checking if we are decreasing or increasing $loop = (($decrease == true) ? '-' : '+'); // Creating the appropriate time stampe $tmsp = strtotime($loop . $i . ' ' . $int); // Building the date array $date_arr[] = date($format, $tmsp); } // Returning the date array return $date_arr; } print_r(wdates(12,7)); ?> Which prints Array ( [0] => 1998 [1] => 1997 [2] => 1996 [3] => 1995 [4] => 1994 [5] => 1993 [6] => 1992 ) ... 7 results rather then 1 more then needed... ---- Server IP: 192.41.42.26 Probable Submitter: 70.133.222.96 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/100988 Del: integrated -- https://master.php.net/note/delete/100988/integrated Del: useless -- https://master.php.net/note/delete/100988/useless Del: bad code -- https://master.php.net/note/delete/100988/bad+code Del: spam -- https://master.php.net/note/delete/100988/spam Del: non-english -- https://master.php.net/note/delete/100988/non-english Del: in docs -- https://master.php.net/note/delete/100988/in+docs Del: other reasons-- https://master.php.net/note/delete/100988 Reject -- https://master.php.net/note/reject/100988 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174170) next »