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', '06 02 2025')); //2025-02-06
Output for 5.6.28, 7.0.14 - 7.1.0
string(10) "2025-02-06" string(16) "02/06/2025 12:37" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 7.0.6
string(10) "2025-02-06" string(16) "02/06/2025 20:46" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 7.0.5
string(10) "2025-02-06" string(16) "02/06/2025 15:22" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 7.0.4
string(10) "2025-02-06" string(16) "02/06/2025 00:49" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 7.0.3
string(10) "2025-02-06" string(16) "02/06/2025 01:01" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 7.0.2
string(10) "2025-02-06" string(16) "02/06/2025 11:37" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 7.0.1
string(10) "2025-02-06" string(16) "02/06/2025 11:48" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 7.0.0
string(10) "2025-02-06" string(16) "02/06/2025 14:20" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for hhvm-3.12.0
string(10) "2025-02-06" string(16) "02/06/2025 05:20" Warning: date_format() expects parameter 1 to be object, boolean given in /in/SJnZR on line 9 bool(false)
Output for hhvm-3.10.0
string(10) "2025-02-06" string(16) "02/06/2025 19:14" Warning: date_format() expects parameter 1 to be object, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.21
string(10) "2025-02-06" string(16) "02/06/2025 22:35" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.20
string(10) "2025-02-06" string(16) "02/06/2025 10:37" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.19
string(10) "2025-02-06" string(16) "02/06/2025 22:59" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.18
string(10) "2025-02-06" string(16) "02/06/2025 10:33" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.17
string(10) "2025-02-06" string(16) "02/06/2025 05:30" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.16
string(10) "2025-02-06" string(16) "02/06/2025 16:05" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.15
string(10) "2025-02-06" string(16) "02/06/2025 16:58" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.14
string(10) "2025-02-06" string(16) "02/06/2025 19:38" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.13
string(10) "2025-02-06" string(16) "02/06/2025 23:25" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.12
string(10) "2025-02-06" string(16) "02/06/2025 12:33" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.11
string(10) "2025-02-06" string(16) "02/06/2025 18:53" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.10
string(10) "2025-02-06" string(16) "02/06/2025 21:02" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.9
string(10) "2025-02-06" string(16) "02/06/2025 03:01" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.6.8
string(10) "2025-02-06" string(16) "02/06/2025 10:47" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.35
string(10) "2025-02-06" string(16) "02/06/2025 13:12" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.34
string(10) "2025-02-06" string(16) "02/06/2025 16:32" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.33
string(10) "2025-02-06" string(16) "02/06/2025 11:44" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.32
string(10) "2025-02-06" string(16) "02/06/2025 17:24" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.31
string(10) "2025-02-06" string(16) "02/06/2025 08:24" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.30
string(10) "2025-02-06" string(16) "02/06/2025 19:00" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.29
string(10) "2025-02-06" string(16) "02/06/2025 13:32" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.28
string(10) "2025-02-06" string(16) "02/06/2025 15:48" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.27
string(10) "2025-02-06" string(16) "02/06/2025 18:21" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.26
string(10) "2025-02-06" string(16) "02/06/2025 23:43" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.25
string(10) "2025-02-06" string(16) "02/06/2025 07:18" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.5.24
string(10) "2025-02-06" string(16) "02/06/2025 14:26" Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.4.41 - 5.4.45
string(10) "2025-02-06" string(16) "02/06/2025 00:30" Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.4.39 - 5.4.40
string(10) "2025-02-06" string(16) "02/06/2025 13:29" Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.4.38
string(10) "2025-02-06" string(16) "02/06/2025 10:15" Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.4.36 - 5.4.37
string(10) "2025-02-06" string(16) "02/06/2025 05:31" Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.4.34 - 5.4.35
string(10) "2025-02-06" string(16) "02/06/2025 21:46" Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.3.29, 5.4.26 - 5.4.32
string(10) "2025-02-06" string(16) "02/06/2025 19:36" Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/SJnZR on line 9 bool(false)
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.25
string(10) "2025-02-06" string(16) "02/06/2025 12:37" Warning: date_format() expects parameter 1 to be DateTime, boolean given in /in/SJnZR 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/SJnZR 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/SJnZR 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/SJnZR 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/SJnZR 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/SJnZR on line 5