Quick Reference
The PHP date_get_last_errors() function returns the warnings/errors found while parsing a date string.
<?php
date_create('huio6urtdglh;oi;7;76iulgb');
print_r(date_get_last_errors());
?>
Output
Array ( [warning_count] => 1 [warnings] => Array ( [5] => Double timezone specification ) [error_count] => 11 [errors] => Array ( [0] => The timezone could not be found in the database [4] => Unexpected character [11] => Double timezone specification [12] => Unexpected character [13] => Double timezone specification [15] => Unexpected character [16] => Unexpected character [17] => Unexpected character [18] => Unexpected character [19] => Unexpected character [20] => Double timezone specification ) )
Syntax
date_get_last_errors()
PHP Notes:
- When using PHP, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.