Im trying to get a list of months between 2 dates, and came up with:-
function echoDate( $start, $end ){
$current = $start;
$ret = array();
while( $current<$end ){
$next = date('Y-M-01', $current) . "+1 month";
$current = strtotime($next);
$ret[] = date("Y-m",$current);
}
return $ret;
}
So, if I ran:-
echoDate(strtotime("2021-09-06"), strtotime("2021-12-26"));
I should get an array of:-
2021-09
2021-10
2021-11
2021-22
But instead I get an array of:-
2021-10
2021-11
2021-12
2022-01
Which I dont understand of where its getting these values from.
Any ideas?