3v4l.org

run code in 300+ PHP versions simultaneously
<?php class WP_JSON_DateTime extends DateTime { /** * Workaround for DateTime::createFromFormat on PHP < 5.3 * Found on http://stackoverflow.com/a/17084893/717643 * * @param string $format The format that the passed in string should be in. * @param string $string String representing the time. * @param DateTimeZone $timezone A DateTimeZone object representing the desired time zone. * @return Datetime */ public static function createFromFormat($format, $time, $timezone = null) { if ( method_exists('DateTime', 'createFromFormat') ) { return parent::createFromFormat($format, $time, $timezone); } return new DateTime(date($format, strtotime($time)), $timezone); } } $timezone = new DateTimeZone('America/Mexico_City'); $date = WP_JSON_DateTime::createFromFormat('Y-m-d H:i:s', '2013-12-14 16:12:03', $timezone); echo $date->format('c'); echo '<br>'; echo $date->format('date_tz');
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of WP_JSON_DateTime::createFromFormat($format, $time, $timezone = null) should either be compatible with DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/WvbPE on line 13 2013-12-14T16:12:03-06:00<br>14pm31America/Mexico_City_31347

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.31 ms | 402 KiB | 8 Q