I have the string
First convert your
yyyymmdd to a DateTime object:
$inputString = "19720505"; $date = DateTime::createFromFormat("Ymd", $inputString);
Then convert your DateTime object to string in desired format:
$outputString = $date->format('Y-m-d H:i:s');
All this operations are considered basic and very simple. You should read PHP Documentation before asking something so basic here.