3v4l.org

run code in 300+ PHP versions simultaneously
<?php function converteData($format, $to_format, $time, $timezone = null) { if (!$timezone) { $timezone = new DateTimeZone(date_default_timezone_get()); } $d = date_create_from_format($format, $date, $timezone); return date_format($d, $to_format); } var_dump(converteData('d/m/Y H:i', 'd/m/Y H:i', '06/11/1992'));
Output for 8.3.0 - 8.3.4
Warning: Undefined variable $date in /in/cJaWO on line 8 Deprecated: date_create_from_format(): Passing null to parameter #2 ($datetime) of type string is deprecated in /in/cJaWO on line 8 Fatal error: Uncaught TypeError: date_format(): Argument #1 ($object) must be of type DateTimeInterface, false given in /in/cJaWO:9 Stack trace: #0 /in/cJaWO(9): date_format(false, 'd/m/Y H:i') #1 /in/cJaWO(12): converteData('d/m/Y H:i', 'd/m/Y H:i', '06/11/1992') #2 {main} thrown in /in/cJaWO on line 9
Process exited with code 255.
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17
Warning: Undefined variable $date in /in/cJaWO on line 8 Deprecated: date_create_from_format(): Passing null to parameter #2 ($datetime) of type string is deprecated in /in/cJaWO on line 8 Fatal error: Uncaught TypeError: date_format(): Argument #1 ($object) must be of type DateTimeInterface, bool given in /in/cJaWO:9 Stack trace: #0 /in/cJaWO(9): date_format(false, 'd/m/Y H:i') #1 /in/cJaWO(12): converteData('d/m/Y H:i', 'd/m/Y H:i', '06/11/1992') #2 {main} thrown in /in/cJaWO on line 9
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $date in /in/cJaWO on line 8 Fatal error: Uncaught TypeError: date_format(): Argument #1 ($object) must be of type DateTimeInterface, bool given in /in/cJaWO:9 Stack trace: #0 /in/cJaWO(9): date_format(false, 'd/m/Y H:i') #1 /in/cJaWO(12): converteData('d/m/Y H:i', 'd/m/Y H:i', '06/11/1992') #2 {main} thrown in /in/cJaWO on line 9
Process exited with code 255.
Output for 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: date in /in/cJaWO on line 8 Warning: date_format() expects parameter 1 to be DateTimeInterface, bool given in /in/cJaWO on line 9 bool(false)
Output for 7.3.32 - 7.3.33
Warning: date_format() expects parameter 1 to be DateTimeInterface, bool given in /in/cJaWO on line 9 bool(false)
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33
Notice: Undefined variable: date in /in/cJaWO on line 8 Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/cJaWO on line 9 bool(false)
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45
Notice: Undefined variable: date in /in/cJaWO on line 8 Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/cJaWO on line 9 bool(false)
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined function date_create_from_format() in /in/cJaWO on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/cJaWO on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/cJaWO on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/cJaWO on line 5

preferences:
230.81 ms | 401 KiB | 308 Q