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('d m Y', 'Y-m-d', '06 02 2025')); //2025-02-06 var_dump(converteData('d-m-Y', 'm/d/Y H:i', '06-02-2025')); //2025-02-06 12:38 var_dump(converteData('Y-m-d', 'l F Y H:i', '2014-02-06')); //Thursday February 2014
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.25, 5.6.28, 7.0.14 - 7.1.0
string(10) "2025-02-06" string(16) "02/06/2025 12:38" string(29) "Thursday February 2014 12:38"
Output for 7.0.6
string(10) "2025-02-06" string(16) "02/06/2025 08:12" string(29) "Thursday February 2014 08:12"
Output for 7.0.5
string(10) "2025-02-06" string(16) "02/06/2025 21:09" string(29) "Thursday February 2014 21:09"
Output for 7.0.4
string(10) "2025-02-06" string(16) "02/06/2025 07:26" string(29) "Thursday February 2014 07:26"
Output for 7.0.3
string(10) "2025-02-06" string(16) "02/06/2025 07:59" string(29) "Thursday February 2014 07:59"
Output for 7.0.2
string(10) "2025-02-06" string(16) "02/06/2025 13:44" string(29) "Thursday February 2014 13:44"
Output for 7.0.1
string(10) "2025-02-06" string(16) "02/06/2025 18:45" string(29) "Thursday February 2014 18:45"
Output for 7.0.0
string(10) "2025-02-06" string(16) "02/06/2025 20:25" string(29) "Thursday February 2014 20:25"
Output for hhvm-3.12.0
string(10) "2025-02-06" string(16) "02/06/2025 22:26" string(29) "Thursday February 2014 22:26"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.21
string(10) "2025-02-06" string(16) "02/06/2025 03:32" string(29) "Thursday February 2014 03:32"
Output for 5.6.20
string(10) "2025-02-06" string(16) "02/06/2025 20:00" string(29) "Thursday February 2014 20:00"
Output for 5.6.19
string(10) "2025-02-06" string(16) "02/06/2025 15:33" string(29) "Thursday February 2014 15:33"
Output for 5.6.18
string(10) "2025-02-06" string(16) "02/06/2025 23:18" string(29) "Thursday February 2014 23:18"
Output for 5.6.17
string(10) "2025-02-06" string(16) "02/06/2025 12:17" string(29) "Thursday February 2014 12:17"
Output for 5.6.16
string(10) "2025-02-06" string(16) "02/06/2025 22:11" string(29) "Thursday February 2014 22:11"
Output for 5.6.15
string(10) "2025-02-06" string(16) "02/06/2025 23:04" string(29) "Thursday February 2014 23:04"
Output for 5.6.14
string(10) "2025-02-06" string(16) "02/06/2025 01:38" string(29) "Thursday February 2014 01:38"
Output for 5.6.13
string(10) "2025-02-06" string(16) "02/06/2025 05:33" string(29) "Thursday February 2014 05:33"
Output for 5.6.12
string(10) "2025-02-06" string(16) "02/06/2025 19:11" string(29) "Thursday February 2014 19:11"
Output for 5.6.11
string(10) "2025-02-06" string(16) "02/06/2025 02:10" string(29) "Thursday February 2014 02:10"
Output for 5.6.10
string(10) "2025-02-06" string(16) "02/06/2025 04:00" string(29) "Thursday February 2014 04:00"
Output for 5.6.9
string(10) "2025-02-06" string(16) "02/06/2025 08:58" string(29) "Thursday February 2014 08:58"
Output for 5.6.8
string(10) "2025-02-06" string(16) "02/06/2025 16:59" string(29) "Thursday February 2014 16:59"
Output for 5.6.7
string(10) "2025-02-06" string(16) "02/06/2025 11:25" string(29) "Thursday February 2014 11:25"
Output for 5.5.35
string(10) "2025-02-06" string(16) "02/06/2025 07:13" string(29) "Thursday February 2014 07:13"
Output for 5.5.34
string(10) "2025-02-06" string(16) "02/06/2025 22:25" string(29) "Thursday February 2014 22:25"
Output for 5.5.33
string(10) "2025-02-06" string(16) "02/06/2025 18:22" string(29) "Thursday February 2014 18:22"
Output for 5.5.32
string(10) "2025-02-06" string(16) "02/06/2025 01:10" string(29) "Thursday February 2014 01:10"
Output for 5.5.31
string(10) "2025-02-06" string(16) "02/06/2025 15:04" string(29) "Thursday February 2014 15:04"
Output for 5.5.30
string(10) "2025-02-06" string(16) "02/06/2025 01:12" string(29) "Thursday February 2014 01:12"
Output for 5.5.29
string(10) "2025-02-06" string(16) "02/06/2025 19:38" string(29) "Thursday February 2014 19:38"
Output for 5.5.28
string(10) "2025-02-06" string(16) "02/06/2025 22:16" string(29) "Thursday February 2014 22:16"
Output for 5.5.27
string(10) "2025-02-06" string(16) "02/06/2025 00:47" string(29) "Thursday February 2014 00:47"
Output for 5.5.26
string(10) "2025-02-06" string(16) "02/06/2025 06:27" string(29) "Thursday February 2014 06:27"
Output for 5.5.25
string(10) "2025-02-06" string(16) "02/06/2025 12:30" string(29) "Thursday February 2014 12:30"
Output for 5.5.24
string(10) "2025-02-06" string(16) "02/06/2025 19:25" string(29) "Thursday February 2014 19:25"
Output for 5.4.41 - 5.4.45
string(10) "2025-02-06" string(16) "02/06/2025 00:29" string(29) "Thursday February 2014 00:29"
Output for 5.4.39 - 5.4.40
string(10) "2025-02-06" string(16) "02/06/2025 13:27" string(29) "Thursday February 2014 13:27"
Output for 5.4.38
string(10) "2025-02-06" string(16) "02/06/2025 10:14" string(29) "Thursday February 2014 10:14"
Output for 5.4.36 - 5.4.37
string(10) "2025-02-06" string(16) "02/06/2025 05:29" string(29) "Thursday February 2014 05:29"
Output for 5.4.34 - 5.4.35
string(10) "2025-02-06" string(16) "02/06/2025 21:45" string(29) "Thursday February 2014 21:45"
Output for 5.3.29, 5.4.26 - 5.4.32
string(10) "2025-02-06" string(16) "02/06/2025 19:32" string(29) "Thursday February 2014 19:32"
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined function date_create_from_format() in /in/TggDG on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/TggDG 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/TggDG on line 18
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/TggDG 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/TggDG on line 5