@ 2015-10-19T20:09:12Z <?php
$start = (new DateTime('1 year ago'))->modify('last day of this month');
$end = (new DateTime())->modify('first day of this month');
$interval = new DateInterval('P1M');
$period = new DatePeriod($start, $interval, $end);
$months = array();
foreach ($period as $dt) {
$months[$dt->format('Y-m-d')] = $dt->format('Y-m');
}
$reverse_months = array_reverse($months);
print_r($reverse_months);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.4.0 - 5.4.45 , 5.6.28 , 7.0.20 , 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 Array
(
[2015-09-01] => 2015-09
[2015-08-01] => 2015-08
[2015-07-01] => 2015-07
[2015-06-01] => 2015-06
[2015-05-01] => 2015-05
[2015-04-01] => 2015-04
[2015-03-01] => 2015-03
[2015-02-01] => 2015-02
[2015-01-01] => 2015-01
[2014-12-01] => 2014-12
[2014-10-31] => 2014-10
)
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[2015-09-01] => 2015-09
[2015-08-01] => 2015-08
[2015-07-01] => 2015-07
[2015-06-01] => 2015-06
[2015-05-01] => 2015-05
[2015-04-01] => 2015-04
[2015-03-01] => 2015-03
[2015-02-01] => 2015-02
[2015-01-01] => 2015-01
[2014-12-01] => 2014-12
[2014-10-31] => 2014-10
)
Output for 5.5.35 , 5.6.7 , 5.6.21 , 7.0.6 Array
(
[2016-04-01] => 2016-04
[2016-03-01] => 2016-03
[2016-02-01] => 2016-02
[2016-01-01] => 2016-01
[2015-12-01] => 2015-12
[2015-11-01] => 2015-11
[2015-10-01] => 2015-10
[2015-09-01] => 2015-09
[2015-08-01] => 2015-08
[2015-07-01] => 2015-07
[2015-05-31] => 2015-05
)
Output for 5.5.24 - 5.5.29 , 5.5.34 , 5.6.8 - 5.6.14 , 5.6.20 , 7.0.5 Array
(
[2016-03-01] => 2016-03
[2016-01-30] => 2016-01
[2015-12-30] => 2015-12
[2015-11-30] => 2015-11
[2015-10-30] => 2015-10
[2015-09-30] => 2015-09
[2015-08-30] => 2015-08
[2015-07-30] => 2015-07
[2015-06-30] => 2015-06
[2015-05-30] => 2015-05
[2015-04-30] => 2015-04
)
Output for 5.5.30 - 5.5.33 , 5.6.15 - 5.6.19 , 7.0.0 - 7.0.4 Array
(
[2016-02-01] => 2016-02
[2016-01-01] => 2016-01
[2015-12-01] => 2015-12
[2015-11-01] => 2015-11
[2015-10-01] => 2015-10
[2015-09-01] => 2015-09
[2015-08-01] => 2015-08
[2015-07-01] => 2015-07
[2015-06-01] => 2015-06
[2015-05-01] => 2015-05
[2015-03-31] => 2015-03
)
preferences:dark mode live preview
202.93 ms | 402 KiB | 243 Q