PHP Looping through a range of dates
by Jay on Sep.10, 2010, under PHP
Problem:
You need to get the individual dates in a date range and store them in an arbitary data structure such as an array
Solution:
$endDate = date(“Y-m-d”, strtotime(‘yesterday’));
$startDate = ’2010-08-01′;$newDate = $startDate;
$arRangeOfDates = array();
while($newDate != $endDate) {
$newDate = date(‘Y-m-d’,strtotime(date(“Y-m-d”, strtotime($newDate)) . ” +1 day”));
$arRangeOfDates[]=$newDate;
}
No comments for this entry yet...