from date object to string php code example
Example 1: Datetime to string php
<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
Example 2: Convert DateTime to String in PHP
phpCopy$date = date_create_from_format('d M, Y', '08 Mar, 2020');
echo $newFormat = date_format($date,"Y/m/d H:i:s");
//output: 2020/03/08 00:00:00