I need to compare only the year and month between two dates, I did it the following way and it works perfectly:
$mes1 = "2018/02";
$mes2 = "2018/03";
if($mes1 > $mes2) {
echo "Mês 1 é maior que mês 2";
}elseif($mes2 > $mes1) {
echo "Mês 2 é maior que mês 1";
}
My question is about good practices, comparing just the year and month so this is correct, or would I need to use some feature of php
to say that it is a date? my fear is that it starts to give an error in some version of php
future.
I do not know what to do, but I do not know what to do.
I know there are several posts that might look similar to but they are not.