3v4l.org

run code in 300+ PHP versions simultaneously
<?php $datetimes = [ '2003-01-28 01:23:45', '2007-04-04', '0000-00-00 00:00:00', '0000-00-00', '', null ]; foreach ($datetimes as $datetime) { sscanf($datetime, '%s', $sscanf); var_export( [ 'substr' => substr($datetime, 0, 10), 'explode' => explode(' ', $datetime, 2)[0], 'sscanf' => $sscanf, 'preg_replace' => preg_replace('/ .+/', '', $datetime), 'format' => (new \DateTime($datetime))->format('Y-m-d'), 'date&strtotime' => date("Y-m-d", strtotime($datetime)), 'strtok' => strtok($datetime, ' '), 'strstr' => strstr($datetime . ' ', ' ', true), ] ); unset($sscanf); echo "\n---\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'substr' => '2003-01-28', 'explode' => '2003-01-28', 'sscanf' => '2003-01-28', 'preg_replace' => '2003-01-28', 'format' => '2003-01-28', 'date&strtotime' => '2003-01-28', 'strtok' => '2003-01-28', 'strstr' => '2003-01-28', ) --- array ( 'substr' => '2007-04-04', 'explode' => '2007-04-04', 'sscanf' => '2007-04-04', 'preg_replace' => '2007-04-04', 'format' => '2007-04-04', 'date&strtotime' => '2007-04-04', 'strtok' => '2007-04-04', 'strstr' => '2007-04-04', ) --- array ( 'substr' => '0000-00-00', 'explode' => '0000-00-00', 'sscanf' => '0000-00-00', 'preg_replace' => '0000-00-00', 'format' => '-0001-11-30', 'date&strtotime' => '-0001-11-30', 'strtok' => '0000-00-00', 'strstr' => '0000-00-00', ) --- array ( 'substr' => '0000-00-00', 'explode' => '0000-00-00', 'sscanf' => '0000-00-00', 'preg_replace' => '0000-00-00', 'format' => '-0001-11-30', 'date&strtotime' => '-0001-11-30', 'strtok' => '0000-00-00', 'strstr' => '0000-00-00', ) --- array ( 'substr' => '', 'explode' => '', 'sscanf' => NULL, 'preg_replace' => '', 'format' => '2021-08-23', 'date&strtotime' => '1970-01-01', 'strtok' => false, 'strstr' => '', ) --- Deprecated: sscanf(): Passing null to parameter #1 ($string) of type string is deprecated in /in/XrNPi on line 13 Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /in/XrNPi on line 16 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/XrNPi on line 17 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/XrNPi on line 19 Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/XrNPi on line 20 Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/XrNPi on line 21 Deprecated: strtok(): Passing null to parameter #1 ($string) of type string is deprecated in /in/XrNPi on line 22 array ( 'substr' => '', 'explode' => '', 'sscanf' => NULL, 'preg_replace' => '', 'format' => '2021-08-23', 'date&strtotime' => '1970-01-01', 'strtok' => false, 'strstr' => '', ) ---

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:
113.66 ms | 415 KiB | 5 Q