It’s really a horrible thing to work on date to being a programmer. If language is PHP then it’s too hard to achieve but don’t worry I have a best trick to solve it just take a look on following lines.
In PHP Date store in string format internally and time is store integer internally. You just have to change date into its equivalent time integer value and compare their integer as we work on number.
echo "First Date is greatest one";
echo "Second Date is greatest one";
I am using function for implement your logic you can work it where you want without using function