Creating strings with the date_create_from_format() function:
<?php
$date = "06/08/04";
echo DateTime::createFromFormat( '!d/m/y', $date )->format( DateTime::ISO8601 ), "\n";
?>
Output
2004-08-06T00:00:00+0000
Parsing strings with the date_parse_from_format() function:
<?php
$date = "06/08/04";
print_r( date_parse_from_format( '!y*d*m', $date ) );
?>
Output
Array
(
[year] => 2006
[month] => 4
[day] => 8
[hour] => 0
[minute] => 0
[second] => 0
[fraction] => 0
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 0
[errors] => Array
(
)
[is_localtime] =>
)