PHP time split problem?

known :
$beginDate = "2018-07";
$endDate = "2018-11";

how to implement :

in code

for example, this month is November, then

2018-11 this month
2018-10 exceeds January
2018-09 exceeds February
2018-08 exceeds March
2018-07 exceeds April

the time after July defaults to "beyond April"

Php
Oct.17,2021

can be implemented using the DateTime class, and DateTime is also an officially recommended method for time calculation

$beginDate = '2018-07;
$endDate =' 2018-02;

$start = new DateTime ($beginDate);
$end = new DateTime ($endDate);

echo sprintf ('past% d months', $end- > diff ($start)-> m > 4? 4: $end- > diff ($start)-> m);


date('m', strtotime('2018-07'))

Why does such a simple logic ask? Instead of trying to write

yourself.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b85f-3464e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b85f-3464e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?