date_get_last_errors()

date_get_last_errors() — Alias of DateTimeImmutable::getLastErrors().

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.3.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

date_get_last_errors() is an alias of DateTimeImmutable::getLastErrors(): same parameters, same return value.

Signature

DateTimeImmutable::getLastErrors(): array|false

Parameters

This function takes no parameters.

Return value

Returns array containing info about warnings and errors, or false if there are neither warnings nor errors.

Example

A runnable snippet:

try { $date = new DateTimeImmutable('asdfasdf'); } catch (Exception $e) { // For demonstration purposes only... print_r(DateTimeImmutable::getLastErrors()); // The real object-oriented way to do this is echo $e->getMessage(); }

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 ) ) Failed to parse time string (asdfasdf) at position 0 (a): The timezone could not be found in the database

All PHP 8.5 built-in functions

Reference card built from the PHP manual page date_get_last_errors() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.