PHP date_get_last_errors() function

6 Jan 2025 | 1 min read

If any error comes while parsing the date string, this function will show warnings/ errors in output.

Syntax

Example 1

Output:

 Array ( [warning_count] => 1 [warnings] => Array ( [4] => Double timezone specification ) [error_count] => 3 [errors] => Array ( [1] => Unexpected character [2] => Unexpected character [3] => Unexpected character ) ) 

Example 2

Output:

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