Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?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($current,'M-y'); } return array_reverse($ret); } $months = echoDate( $StartDate, $StopDate ); var_dump($months);
Copy Clear