How to convert from dmy to d-m-y, using this code, but this method is not what I want.
$source = '05032020';
$date = new DateTime($source);
echo $date->format('d.m.Y'); // 05-03-2020
How to convert from dmy to d-m-y, using this code, but this method is not what I want.
$source = '05032020';
$date = new DateTime($source);
echo $date->format('d.m.Y'); // 05-03-2020
Try this.
$source = '05032020';
$date = date_create_from_format('dmY', $source);
echo $date->format('d-m-Y'); //05-03-2020