Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$StartDate = @strtotime("Apr 2023");
$StopDate = @strtotime("Mar 2024");
/**
* Gets list of months between two dates
* @param int $start Unix timestamp
* @param int $end Unix timestamp
* @return array
*/
function echoDate( $start, $end ){
$current = $start;
$ret = array();
while( $current<$end ){
$next = @date('Y-M-01', $current) . "+1 month";
$current = @strtotime($next);
$ret[] = date($next,'M-y');
}
return array_reverse($ret);
}
$months = echoDate( $StartDate, $StopDate );
var_dump($months);