Check Date in PHP


 

Check Date in PHP

The PHP Checkdate function is used for validating the system date. It validate the Gregorian date. It returns 'True' if finds the specified date valid, otherwise it returns false.

The PHP Checkdate function is used for validating the system date. It validate the Gregorian date. It returns 'True' if finds the specified date valid, otherwise it returns false.

Check Date in PHP

The Checkdate()

The PHP Checkdate function is used for validating the system date. It validate the Gregorian date. It returns 'True' if finds the specified date valid, otherwise it returns false.

Note: A Gregorian date is valid if 

  • the month is specified between 1 to 12 
  • the day is within the allowed number of days for the particular month
  • the year is between 1 and 32767 inclusive

Syntax
checkdate(month,day,year)

Parameter Description

month - month is essential parameter that specifies a month
day - Essential that specifies the day
year - year is also necessary that denotes the year. 

Example

<?php
var_dump(checkdate(07,31,2009));
var_dump(checkdate(2,29,2009));
var_dump(checkdate(2,29,2008));
?>

The output of the code above will be:
bool(true)
bool(false)
bool(true)

 

Ads