How To Use Function checkdate() Using PHP

Good Day!!!

In this tutorial, we are going to learn PHP function, and it's called "checkdate()". The checkdate() function returns true if the specified date is valid, and false otherwise.
A date is valid if:
  • month - is between 1 and 12 inclusive
  • day - is within the allowed number of days for the particular month
  • year - is between 1 and 32767 inclusive
This function has this form: checkdate(month,day,year) month - specifies the month (between 1 and 12 inclusive ). (required) day - specifies the day (within the allowed number of days for the given month). (required) year - specifies the year (between 1 and 32767 inclusive). (required)
Example:
The following example shows the basic use of this function.
  1. <?php
  2. var_dump(checkdate(12,31,2000));
  3. var_dump(checkdate(2,29,2003));
  4. var_dump(checkdate(2,29,2004));
  5. ?>
This produces the following result: bool(true) bool(false) bool(true)

Tags

Add new comment