Get the warnings and errors with creating DateTime object in PHP
Description
The following code shows how to get the warnings and errors with creating DateTime object.
Example
// w w w .ja v a2 s . co m
<?php
try {
$date = new DateTime('asdfasdf');
} catch (Exception $e) {
// For demonstration purposes only...
print_r(DateTime::getLastErrors());
// The real object oriented way to do this is
// echo $e->getMessage();
}
?>
The code above generates the following result.