3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $fourHours = new DateInterval('P4H'); $dateString = '01-01T23:59'; $defaultLastTicketingDate = new \DateTime('2015-12-31T22:00'); $defaultLastTicketingDate->add($fourHours); $deadline = new \DateTime($defaultLastTicketingDate->format('Y') . '-' . $dateString); if ($deadline < $defaultLastTicketingDate) { $nextYear = new \DateTime('+1 Year'); $deadline = new \DateTime($nextYear->format('Y') . '-' . $dateString); } echo $deadline->format('c');
based on pmINA
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Exception: DateInterval::__construct(): Unknown or bad format (P4H) in /in/rt9CZ:3 Stack trace: #0 /in/rt9CZ(3): DateInterval->__construct('P4H') #1 {main} thrown in /in/rt9CZ on line 3
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (P4H)' in /in/rt9CZ:3 Stack trace: #0 /in/rt9CZ(3): DateInterval->__construct('P4H') #1 {main} thrown in /in/rt9CZ on line 3
Process exited with code 255.