note 100245 deleted from function.date by rquadling

From: Date: Mon, 04 Oct 2010 11:09:19 +0000
Subject: note 100245 deleted from function.date by rquadling
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172929@lists.php.net to get a copy of this message
Note Submitter: imran at t555 dot net ---- Here is a simple function that works out the dates between 2 given dates: <?php function dates_inbetween($date1, $date2){ $day = 60*60*24; $date1 = strtotime($date1); $date2 = strtotime($date2); $days_diff = (($date2 - $date1)/$day); // Unix time difference devided by 1 day to get total days in between $dates_array = array(); $dates_array[] = date('Y-m-d',$date1); for($x = 1; $x <= $days_diff; $x++){ $dates_array[] = date('Y-m-d',($date1+($day*$x))); } return $dates_array; } ?> Usage: <?php print_r(dates_inbetween('2001-08-28', '2001-09-01')); ?>

« previous php.notes (#172929) next »