Proper date checking for PHP

Some sites seem to perform a simple date check where they just check if “Day” is a number between 1 to 31, “Month” is a number between 1 to 12 and the “Year” is a valid number.

While this check is inexpensive, it is definitely wrong as you may end up with strange combinations such as “31st April 2010” or you may also wrongly allow “29th February” to occur on non-leap years.

To save yourself some grief, make sure you use the checkdate() function to validate your date data.

Leave a Reply

Your email address will not be published. Required fields are marked *