How to compare two dates

You can use built-in ISO8601DateTime methods for that: equalsTo(), laterThan(), and earlierThan().

But, as usual, ask yourself a question what you really need. Chances are you don’t need to compare; you need a maximum or minimum date instead. If so, I’ve got you covered: Min and Max are what you’re looking for:

$m =
   new Max(
      new Now(),
      new Future(
         new FromISO8601('1986-05-04 00:30:00+03'),
         new NYears(34)
      )
   );

After you got what you need, you can proceed to textual representation. value() method returns an ISO8601 string value. There are fancier ways to format datetime either.