3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @link https://stackoverflow.com/a/13129856/367456 */ $formats = array( 'today midnight', 'midnight', 'today', 'TODAY', 'MidNight', 'ToDaY', 'tomorrow', 'UTC today', 'today Z', 'today Europe/Berlin', 'Asia/Shanghai today', 'Asia/Shanghai', 'HKST today', ); /** * give each time (unix timestamp) its own color * * @param $time * @return string */ function time_color($time) { static $colors = array('black', 'copper', 'blue', 'lime', 'green', 'pink', 'red'); static $coloredTime = array(-1 => ' ?! '); if (!isset($coloredTime[$time])) { $coloredTime[$time] = array_pop($colors); } return $coloredTime[$time]; } $time = strtotime('UTC 2020-01-01 00:00:00'); $format1 = "(default time-zone is ..: %s)\n"; if (is_callable('date_default_timezone_get')) { printf($format1, date_default_timezone_get()); } else { printf($format1, '??? (unknown)'); } printf("UTC time is ............: [%-6s] %d (script-time, UTC 2020-01-01 00:00:00)\n", time_color($time), $time); foreach ($formats as $format) { $strToTime = strtotime($format, $time); printf("%'.-24s: [%-6s] %d\n", "$format ", time_color($strToTime), $strToTime); }
Output for git.master, git.master_jit, rfc.property-hooks
(default time-zone is ..: Europe/Amsterdam) UTC time is ............: [red ] 1577836800 (script-time, UTC 2020-01-01 00:00:00) today midnight .........: [pink ] 1577833200 midnight ...............: [pink ] 1577833200 today ..................: [pink ] 1577833200 TODAY ..................: [pink ] 1577833200 MidNight ...............: [pink ] 1577833200 ToDaY ..................: [pink ] 1577833200 tomorrow ...............: [green ] 1577919600 UTC today ..............: [red ] 1577836800 today Z ................: [red ] 1577836800 today Europe/Berlin ....: [pink ] 1577833200 Asia/Shanghai today ....: [lime ] 1577808000 Asia/Shanghai ..........: [blue ] 1577811600 HKST today .............: [copper] 1577804400

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:
26.29 ms | 407 KiB | 5 Q