3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 wednesday 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( 'first 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";
based on jCmC6
Output for 5.6.0 - 5.6.30, hhvm-3.18.5, hhvm-3.22.0, 7.0.0 - 7.3.0beta1
February 4 01.02.2018, 11:37:07 02.2018 February 3 28.02.2018, 00:00:00 02.2018 March 4 01.03.2018, 00:00:00 03.2018
Output for hhvm-3.21.3
February 4 01.02.2018, 11:37:08 02.2018 February 3 28.02.2018, 00:00:00 02.2018 March 4 01.03.2018, 00:00:00 03.2018