Home  >  Article  >  Backend Development  >  How to use php checkdate function

How to use php checkdate function

藏色散人
藏色散人Original
2019-02-21 16:20:443725browse

The checkdate function is a built-in function of PHP. Its syntax is "checkdate(month, day, year)", which is used to verify a Gregorian date and check the legality of the date composed of parameters.

How to use php checkdate function

Recommended: "PHP Video Tutorial"

The checkdate() function is a built-in function of PHP , the syntax is checkdate(month,day,year), used to verify a Gregorian date and check the legality of the date composed of parameters. Each parameter is considered valid if it is defined correctly.

How to use php checkdate() function?

Function: Verify a Gregorian date

Syntax:

checkdate(month,day,year)

Parameters:

month Required. Specifies the month, a numeric value from 1 to 12.

day Required. Specifies the day, a numeric value from 1 to 31.

year Required. Specifies the year, a numeric value from 1 to 32767.

Return value: This function returns a Boolean value. Returns true if the date is a valid date, false otherwise.

Description: Check if some dates are valid Gregorian dates.

php checkdate() function example

<?php
var_dump(checkdate(12,31,-220));
echo "<br>";
var_dump(checkdate(2,29,2003));
echo "<br>";
var_dump(checkdate(2,29,2004));
?>

Output:

bool(false) 
bool(false) 
bool(true)

This article is about the use of checkdate function. I hope it will help those who need it. Friends help!

The above is the detailed content of How to use php checkdate function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn