I am trying to loop through dates with PHP. Currently my code gets stuck in a loop repeating 110307. I need the date format to be in yymmdd. Here is what I was trying to use:
strtotime
interprets "100227" as the time 10:02:27 today, not 2010-02-27. So after the first step, $check_date
(today) is "110307". At all subsequent steps "110307" is again interpreted as a time today, giving $check_date
as "110307" again.
A neat trick for iterating dates is to take advantage of mktime's ability to normalize dates, something like this:
$date_arr = array(27,2,2010);
$end_date = "100324";
do {
$check_date = gmdate('ymd', gmmktime(0,0,0,$date_arr[1],$date_arr[0]++,$date_arr[2]));
echo $check_date."\n";
} while($end_date!=$check_date);