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-2014')); //2014-02-06 12:38 var_dump(converteData('Y-m-d', 'l F Y H:i', '2014-02-06')); //Thursday February 2014 12:38
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/2014 12:39" string(29) "Thursday February 2014 12:39"
Output for 7.0.6
string(10) "2025-02-06" string(16) "02/06/2014 02:06" string(29) "Thursday February 2014 02:06"
Output for 7.0.5
string(10) "2025-02-06" string(16) "02/06/2014 15:22" string(29) "Thursday February 2014 15:22"
Output for 7.0.4
string(10) "2025-02-06" string(16) "02/06/2014 00:49" string(29) "Thursday February 2014 00:49"
Output for 7.0.3
string(10) "2025-02-06" string(16) "02/06/2014 01:01" string(29) "Thursday February 2014 01:01"
Output for 7.0.2
string(10) "2025-02-06" string(16) "02/06/2014 11:37" string(29) "Thursday February 2014 11:37"
Output for 7.0.1
string(10) "2025-02-06" string(16) "02/06/2014 11:48" string(29) "Thursday February 2014 11:48"
Output for 7.0.0
string(10) "2025-02-06" string(16) "02/06/2014 14:20" string(29) "Thursday February 2014 14:20"
Output for hhvm-3.12.0
string(10) "2025-02-06" string(16) "02/06/2014 05:20" string(29) "Thursday February 2014 05:20"
Output for hhvm-3.10.0
string(10) "2025-02-06" string(16) "02/06/2014 19:14" string(29) "Thursday February 2014 19:14"
Output for 5.6.21
string(10) "2025-02-06" string(16) "02/06/2014 21:09" string(29) "Thursday February 2014 21:09"
Output for 5.6.20
string(10) "2025-02-06" string(16) "02/06/2014 10:37" string(29) "Thursday February 2014 10:37"
Output for 5.6.19
string(10) "2025-02-06" string(16) "02/06/2014 22:59" string(29) "Thursday February 2014 22:59"
Output for 5.6.18
string(10) "2025-02-06" string(16) "02/06/2014 10:33" string(29) "Thursday February 2014 10:33"
Output for 5.4.36 - 5.4.37, 5.6.17
string(10) "2025-02-06" string(16) "02/06/2014 05:30" string(29) "Thursday February 2014 05:30"
Output for 5.6.16
string(10) "2025-02-06" string(16) "02/06/2014 16:05" string(29) "Thursday February 2014 16:05"
Output for 5.6.15
string(10) "2025-02-06" string(16) "02/06/2014 16:58" string(29) "Thursday February 2014 16:58"
Output for 5.6.14
string(10) "2025-02-06" string(16) "02/06/2014 19:38" string(29) "Thursday February 2014 19:38"
Output for 5.6.13
string(10) "2025-02-06" string(16) "02/06/2014 23:25" string(29) "Thursday February 2014 23:25"
Output for 5.6.12
string(10) "2025-02-06" string(16) "02/06/2014 12:33" string(29) "Thursday February 2014 12:33"
Output for 5.6.11
string(10) "2025-02-06" string(16) "02/06/2014 19:50" string(29) "Thursday February 2014 19:50"
Output for 5.6.10
string(10) "2025-02-06" string(16) "02/06/2014 21:29" string(29) "Thursday February 2014 21:29"
Output for 5.6.9
string(10) "2025-02-06" string(16) "02/06/2014 02:38" string(29) "Thursday February 2014 02:38"
Output for 5.4.38, 5.6.8
string(10) "2025-02-06" string(16) "02/06/2014 10:14" string(29) "Thursday February 2014 10:14"
Output for 5.6.7
string(10) "2025-02-06" string(16) "02/06/2014 20:54" string(29) "Thursday February 2014 20:54"
Output for 5.5.35
string(10) "2025-02-06" string(16) "02/06/2014 00:26" string(29) "Thursday February 2014 00:26"
Output for 5.5.34
string(10) "2025-02-06" string(16) "02/06/2014 16:32" string(29) "Thursday February 2014 16:32"
Output for 5.5.33
string(10) "2025-02-06" string(16) "02/06/2014 11:44" string(29) "Thursday February 2014 11:44"
Output for 5.5.32
string(10) "2025-02-06" string(16) "02/06/2014 17:24" string(29) "Thursday February 2014 17:24"
Output for 5.5.31
string(10) "2025-02-06" string(16) "02/06/2014 08:24" string(29) "Thursday February 2014 08:24"
Output for 5.5.30
string(10) "2025-02-06" string(16) "02/06/2014 19:00" string(29) "Thursday February 2014 19:00"
Output for 5.5.29
string(10) "2025-02-06" string(16) "02/06/2014 13:32" string(29) "Thursday February 2014 13:32"
Output for 5.5.28
string(10) "2025-02-06" string(16) "02/06/2014 15:48" string(29) "Thursday February 2014 15:48"
Output for 5.5.27
string(10) "2025-02-06" string(16) "02/06/2014 18:21" string(29) "Thursday February 2014 18:21"
Output for 5.5.26
string(10) "2025-02-06" string(16) "02/06/2014 23:47" string(29) "Thursday February 2014 23:47"
Output for 5.5.25
string(10) "2025-02-06" string(16) "02/06/2014 05:55" string(29) "Thursday February 2014 05:55"
Output for 5.4.39, 5.5.24
string(10) "2025-02-06" string(16) "02/06/2014 13:27" string(29) "Thursday February 2014 13:27"
Output for 5.4.41 - 5.4.45
string(10) "2025-02-06" string(16) "02/06/2014 00:29" string(29) "Thursday February 2014 00:29"
Output for 5.4.40
string(10) "2025-02-06" string(16) "02/06/2014 13:28" string(29) "Thursday February 2014 13:28"
Output for 5.4.34 - 5.4.35
string(10) "2025-02-06" string(16) "02/06/2014 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/2014 19:33" string(29) "Thursday February 2014 19:33"
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined function date_create_from_format() in /in/mi4C9 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/mi4C9 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/mi4C9 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/mi4C9 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/mi4C9 on line 5