PHP checkdate() Function

In this chapter you will learn:

  1. Definition for PHP checkdate() Function
  2. Syntax for PHP checkdate() Function
  3. Parameter for PHP checkdate() Function
  4. Return value from PHP checkdate() Function
  5. Example - validate a Gregorian date

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.

Next chapter...

What you will learn in the next chapter:

  1. Definition for PHP date() Function
  2. Syntax for PHP date() Function
  3. Parameter for PHP date() Function
  4. Return value for PHP date() Function
  5. Example - prints out the current time in 24-hour clock format
  6. Example - This next example outputs the date in the format of 31st of August 2012
Home » PHP Tutorial » PHP Date Functions
PHP checkdate() Function
PHP date() Function
PHP date_add() Function
PHP date_create() Function
PHP date_create_from_format() Function
PHP date_date_set() Function
PHP date_default_timezone_get() Function
PHP date_default_timezone_set() Function
PHP date_diff() Function
PHP date_format() Function
PHP date_get_last_errors() Function
PHP date_interval_format() Function
PHP date_isodate_set() Function
PHP date_modify() Function
PHP date_offset_get() Function
PHP date_parse() Function
PHP date_parse_from_format() Function
PHP date_sub() Function
PHP date_sun_info() Function
PHP date_sunrise() Function
PHP date_sunset() Function
PHP date_time_set() Function
PHP date_timestamp_get() Function
PHP date_timestamp_set() Function
PHP date_timezone_get() Function
PHP date_timezone_set() Function
PHP getdate() Function
PHP gettimeofday() Function
PHP gmdate() Function
PHP gmmktime() Function
PHP gmstrftime() Function
PHP idate() Function
PHP localtime() Function
PHP microtime() Function
PHP mktime() Function
PHP strftime() Function
PHP strptime() Function
PHP strtotime() Function
PHP time() Function
PHP Timezones Constant
PHP timezone_abbreviations_list() Function
PHP timezone_identifiers_list() Function
PHP timezone_location_get() Function
PHP timezone_name_from_abbr() Function
PHP timezone_name_get() Function
PHP timezone_offset_get() Function
PHP timezone_open() Function
PHP timezone_version_get() Function