DateTime::getLastErrors()

It returns the warnings and errors .
Example

<?php
echo “<pre>”;
try {
$date = new DateTime(‘phpcodez’);
} catch (Exception $e) {
print_r(DateTime::getLastErrors());
}
?>

Output

Array
(
[warning_count] => 1
[warnings] => Array
(
[6] => Double timezone specification
)

[error_count] => 1
[errors] => Array
(
[0] => The timezone could not be found in the database
)

)

Share