note 100251 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 20:53:27 +0000
Subject: note 100251 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185971@lists.php.net to get a copy of this message
Note Submitter: imran at t555 dot net ---- Here is a simple function that gets all the dates between 2 given dates and returns an array (including the dates specified): <?php function dates_inbetween($date1, $date2){ $day = 60*60*24; $date1 = strtotime($date1); $date2 = strtotime($date2); $days_diff = round(($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))); } $dates_array[] = date('Y-m-d',$date2); return $dates_array; } // Usage $dates_array = dates_inbetween('2001-12-28', '2002-01-01'); ?>

« previous php.notes (#185971) next »