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