3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php print "System Timezone: ". date_default_timezone_get() ."\n\n"; $inputDate = "5/30/18"; $formatter = new IntlDateFormatter('en-US', IntlDateFormatter::SHORT, IntlDateFormatter::NONE, 'Europe/Berlin'); $timestamp = $formatter->parse($inputDate); print "Using date:\n"; print "Timestamp: {$timestamp}\n"; print "Formatted: ". date(\DateTime::ATOM ." e", $timestamp) ."\n"; print "MySQL: ". date("Y-m-d H:i:s", $timestamp) ."\n"; print "\n\nUsing DateTime(Immutable):\n"; $dt = \DateTimeImmutable::createFromFormat("!U", $timestamp); print "Formatted: ". $dt->format(\DateTime::ATOM ." e") ."\n"; print "MySQL: ". $dt->format("Y-m-d H:i:s") ."\n";
based on Z2oBr
Output for 7.3.0alpha1 - 7.3.0beta1
System Timezone: Europe/Amsterdam Fatal error: Uncaught Error: Class 'IntlDateFormatter' not found in /in/YTTLD:5 Stack trace: #0 {main} thrown in /in/YTTLD on line 5
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.2.6
System Timezone: Europe/Amsterdam Using date: Timestamp: 1527631200 Formatted: 2018-05-30T00:00:00+02:00 Europe/Amsterdam MySQL: 2018-05-30 00:00:00 Using DateTime(Immutable): Formatted: 2018-05-29T22:00:00+00:00 +00:00 MySQL: 2018-05-29 22:00:00
Output for hhvm-3.22.0
System Timezone: Europe/Amsterdam Using date: Timestamp: 1527631200 Formatted: 2018-05-30T00:00:00+02:00 Europe/Amsterdam MySQL: 2018-05-30 00:00:00 Using DateTime(Immutable): Fatal error: Uncaught TypeError: Argument 2 passed to DateTimeImmutable::createFromFormat() must be an instance of string, int given in /in/YTTLD:-1 Stack trace: #0 /in/YTTLD(-1): DateTimeImmutable::createFromFormat() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
System Timezone: Europe/Amsterdam Using date: Timestamp: 1527631200 Formatted: 2018-05-30T00:00:00+02:00 Europe/Amsterdam MySQL: 2018-05-30 00:00:00 Using DateTime(Immutable): Fatal error: Uncaught TypeError: Argument 2 passed to DateTimeImmutable::createFromFormat() must be an instance of string, int given in /in/YTTLD:14 Stack trace: #0 /in/YTTLD(14): DateTimeImmutable::createFromFormat() #1 {main}
Process exited with code 255.