PHP checkdate() FunctionCheck if several dates are valid Gregorian dates:

Definition

The checkdate() function can validate a Gregorian date.

Syntax

PHP checkdate() Function has the following syntax.

checkdate(month,day,year);

Parameter

ParameterIs RequiredDescription
monthRequired.Month value as a number between 1 and 12
dayRequired.Day value as a number between 1 and 31
yearRequired.Year value as a number between 1 and 32767

Return

PHP checkdate() Function returns TRUE if the date is valid. FALSE otherwise.

Example

Validate a Gregorian date


<?php
var_dump(checkdate(2,29,2004));
var_dump(checkdate(2,31,2004));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions