3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $begin = new DateTime( '2015-01-01' ); $end = new DateTime( '2017-12-26' ); $interval = new DateInterval('P6M'); $period = new DatePeriod($begin, $interval, $end); foreach ( $period as $dt ) $endDate = (new $dt)->add($interval)->sub(new DateInterval('PT1D')); echo sprintf("%s-%s\n", $dt->format("Y-m-d"), $endDate->format("Y-m-d"));
based on j7oOi
Output for 7.0.0 - 7.3.1
Fatal error: Uncaught Exception: DateInterval::__construct(): Unknown or bad format (PT1D) in /in/k9vpk:11 Stack trace: #0 /in/k9vpk(11): DateInterval->__construct('PT1D') #1 {main} thrown in /in/k9vpk on line 11
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct: Invalid interval (PT1D)' in /in/k9vpk:-1 Stack trace: #0 /in/k9vpk(-1): DateInterval->__construct() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct: Invalid interval (PT1D)' in /in/k9vpk:11 Stack trace: #0 /in/k9vpk(11): DateInterval->__construct() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (PT1D)' in /in/k9vpk:11 Stack trace: #0 /in/k9vpk(11): DateInterval->__construct('PT1D') #1 {main} thrown in /in/k9vpk on line 11
Process exited with code 255.