dates as string php code example
Example 1: pasar datetime a string php
$theDate = new DateTime('2020-03-08');
echo $stringDate = $theDate->format('Y-m-d H:i:s');
//output: 2020-03-08 00:00:00
Example 2: pasar datetime a string php
$dateFormat = new DateTime(); // this will return current date
echo $stringDate = $date->format(DATE_ATOM);
//output: 2020-03-08T12:54:56+01:00