DateTime::format()

It Returns date formatted according to given format
Example

<?php
$date = new DateTime(‘2007-05-17’);
echo $date->format(‘Y-m-d H:i:s’);
?>

Output

2007-05-17 00:00:00