3v4l.org

run code in 300+ PHP versions simultaneously
<?php $time_str = '1:47 PM'; $tz_str = 'America/New_York'; $timestamp = time(); $datetime = new DateTime("now", new DateTimeZone($tz_str)); //first argument "must" be a string $datetime->setTimestamp($timestamp); //adjust the object to correct timestamp //$datetime = new DateTime( '2010-05' ); $datetime->modify( 'first day of +0 month' ); echo $datetime->format( 'F' ), "\n"; echo $datetime->format('w d.m.Y, H:i:s') . "\n"; echo $datetime->format('m.Y') . "\n"; $datetime->modify( 'fourth thursday of +0 month' ); echo $datetime->format( 'F' ), "\n"; echo $datetime->format('w d.m.Y, H:i:s') . "\n"; echo $datetime->format('m.Y') . "\n"; $datetime->modify( 'third day of +1 month' ); echo $datetime->format( 'F' ), "\n"; echo $datetime->format('w d.m.Y, H:i:s') . "\n"; echo $datetime->format('m.Y') . "\n";
Output for 5.6.0 - 5.6.13, 5.6.16 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0
February 4 01.02.2018, 11:39:20 02.2018 February 4 22.02.2018, 00:00:00 02.2018 Warning: DateTime::modify(): Failed to parse time string (third day of +1 month) at position 10 (o): The timezone could not be found in the database in /in/33bTf on line 19 February 4 22.02.2018, 00:00:00 02.2018
Output for 5.6.14 - 5.6.15
February 4 01.02.2018, 11:39:21 02.2018 February 4 22.02.2018, 00:00:00 02.2018 Warning: DateTime::modify(): Failed to parse time string (third day of +1 month) at position 10 (o): The timezone could not be found in the database in /in/33bTf on line 19 February 4 22.02.2018, 00:00:00 02.2018

preferences:
113.7 ms | 402 KiB | 154 Q