3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function converteData($format, $to_format, $date, $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); } /* * Exemplos */ var_dump(converteData('2014-02-28 12:12:12')); # true var_dump(converteData('2014-02-30 12:12:12')); # false var_dump(converteData('2014-02-28', 'Y-m-d')); # true var_dump(converteData('28/02/2014', 'd/m/Y')); # true var_dump(converteData('30/02/2014', 'd/m/Y')); # false
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function converteData(), 1 passed in /in/2GF0m on line 16 and at least 3 expected in /in/2GF0m:2 Stack trace: #0 /in/2GF0m(16): converteData('2014-02-28 12:1...') #1 {main} thrown in /in/2GF0m on line 2
Process exited with code 255.
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.0.14
Warning: Missing argument 2 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Notice: Undefined variable: to_format in /in/2GF0m on line 9 Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 2 for converteData(), called in /in/2GF0m on line 17 and defined in /in/2GF0m on line 2 Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 17 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Notice: Undefined variable: to_format in /in/2GF0m on line 9 Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 18 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 19 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 20 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/2GF0m on line 9 bool(false)
Output for hhvm-3.12.0
Warning: converteData() expects at least 3 parameters, 1 given in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Fatal error: Uncaught TypeError: Argument 2 passed to date_create_from_format() must be an instance of string, null given in /in/2GF0m:8 Stack trace: #0 /in/2GF0m(8): date_create_from_format() #1 /in/2GF0m(16): converteData() #2 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Warning: converteData() expects at least 3 parameters, 1 given in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Catchable fatal error: Argument 2 passed to date_create_from_format() must be an instance of string, null given in /in/2GF0m on line 8
Process exited with code 255.
Output for 5.3.0 - 5.4.45
Warning: Missing argument 2 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Notice: Undefined variable: to_format in /in/2GF0m on line 9 Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 2 for converteData(), called in /in/2GF0m on line 17 and defined in /in/2GF0m on line 2 Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 17 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Notice: Undefined variable: to_format in /in/2GF0m on line 9 Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 18 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 19 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/2GF0m on line 9 bool(false) Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 20 and defined in /in/2GF0m on line 2 Notice: Undefined variable: date in /in/2GF0m on line 8 Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/2GF0m on line 9 bool(false)
Output for 5.2.0 - 5.2.17
Warning: Missing argument 2 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Fatal error: Call to undefined function date_create_from_format() in /in/2GF0m on line 8
Process exited with code 255.
Output for 5.1.1 - 5.1.6
Warning: Missing argument 2 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Warning: Missing argument 3 for converteData(), called in /in/2GF0m on line 16 and defined in /in/2GF0m on line 2 Fatal error: Class 'DateTimeZone' not found in /in/2GF0m on line 5
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/2GF0m on line 20
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Missing argument 2 for converteData() in /in/2GF0m on line 2 Warning: Missing argument 3 for converteData() in /in/2GF0m on line 2 Fatal error: Class 'DateTimeZone' not found in /in/2GF0m on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Missing argument 2 for convertedata() in /in/2GF0m on line 2 Warning: Missing argument 3 for convertedata() in /in/2GF0m on line 2 Fatal error: Cannot instantiate non-existent class: datetimezone in /in/2GF0m on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Missing argument 2 for convertedata() in /in/2GF0m on line 2 Warning: Missing argument 3 for convertedata() in /in/2GF0m on line 2 Fatal error: Cannot instantiate non-existent class: datetimezone in /in/2GF0m on line 5