The date_get_last_errors() function is an inbuilt function in PHP which is used to returns the warnings and errors. This function parse a date/time string and returns an array of warnings and errors.
Syntax:
- Procedural style:
array date_get_last_errors( void )
- Object oriented style:
array DateTime::getLastErrors( void )
Parameters: This function does not accept any parameter.
Return Value: This function returns an array containing information about warnings and errors.
Below programs illustrate the date_get_last_errors() function in PHP:
Program 1:
<?php $date = date_create(); print_r(date_get_last_errors()); ?> |
Array
(
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 0
[errors] => Array
(
)
)
Program 2:
<?php try { $date = new DateTime('vgdgh'); } catch (Exception $e) { // For demonstration purposes only... print_r(DateTime::getLastErrors()); } ?> |
Array
(
[warning_count] => 0
[warnings] => Array
(
)
[error_count] => 1
[errors] => Array
(
[0] => The timezone could not be found in the database
)
)
Related Articles:
Reference: http://php.net/manual/en/datetime.getlasterrors.php
Recommended Posts:
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
- PHP | stream_get_transports() Function
- PHP | Ds\Deque pop() Function
- PHP | SimpleXMLElement children() Function
- PHP | array_intersect_ukey() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

