DateTime::__construct()

Its creates new DateTime object .

Example

<?php
try {
$date = new DateTime(‘2008-05-17’);
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}

echo $date->format(‘Y-m-d’);
?>

Output

2007-05-15

Share