- var_dump: documentation ( source)
- date_create_from_format: documentation ( source)
- date_format: documentation ( source)
- date_default_timezone_get: documentation ( source)
<?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'));