datetime from format 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: php datetime create
$date = DateTime::createFromFormat('d-m-Y', '15-12-2020');
Example 3: datetime php
$dateTime = new \DateTime();
$dateTime->format('Y-m-d H:i:s');