Share on Google+Share on Google+

Check Date in PHP

Advertisement
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)

 

Advertisements

Advertisement

Posted on: August 25, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.