3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dateinterval1 = new DateInterval('PT1H'); $baseDate = new DateTimeImmutable(); $date1 = $baseDate->add($dateinterval1); $string1 = $dateinterval1->format('%y years %m months %d days %h hours %i minutes %s seconds'); $dateinterval2 = DateInterval::createFromDateString($string1); $date2 = $baseDate->add($dateinterval2); $string2 = $dateinterval2->format('%y years %m months %d days %h hours %i minutes %s seconds'); if ($string1 == $string2) { print "Formats are equal\n"; } if ($date1 == $date2) { print "Objects are equal\n"; } if ($date1->getTimestamp() == $date2->getTimestamp()) { print "Timestamp are equal\n"; }
based on XhoJ8
Output for 5.5.4 - 5.6.30, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.1.7
Formats are equal Objects are equal Timestamp are equal
Output for 5.5.0 - 5.5.3
Formats are equal Timestamp are equal