i have these code,
$end = strtotime ('last day of previous month') ;
$start = strtotime ("-1 year +1 day", $end) ;
$new ['first'] = date ('Y-m-d',$start) ;
$new ['last'] = date ('Y-m-d',$end) ;
$interval = DateInterval::createFromDateString ('1 month') ;
$period = new DatePeriod($start, $interval, $end) ;
foreach ($periods as $period) {
print_r($period -> date_format('Y-m')) ; echo "<br>";
}
but, I have returned by this message:
An uncaught Exception was encountered
Type: Exception
Message: DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments.
anyone can help me?