Jennifer Zelazny

Random and Opinionated Thoughts

Check for Valid Date with PHP

Posted by: Jennifer Zelazny | 0 Comments

I stumbled on this handy function this morning when putting together a form that required a valid date (example: 02/30/2011 would not be valid because there are not 30 days in February). Very simple and useful!

checkdate ( int $month , int $day , int $year )

Checks the validity of the date formed by the arguments. A date is considered valid if each parameter is properly defined.