Having a PEBKAC on this date array... I can't figure out why first position of second dimension overwrites with the last modification of the date... All help is much appreciated!
$year=date('Y');
$count=date('m'); //loop from begining of current year to current month
$begin =new DateTime("$year-01-01");
$end = clone $begin;
for ($i=0; $i < $count; $i++){
if ($i >0){
$begin=$begin->add(new DateInterval('P1M'));
$end = clone $begin;
}
$dateArray[$i][0]=$begin;
$dateArray[$i][1]=$end->modify('last day of this month');
}
The output I am looking for is to have a multi dimensional array that has the first date and last date of each month from current year to current month.