Home  >  Article  >  Backend Development  >  How to use php checkdate() function to check the date

How to use php checkdate() function to check the date

怪我咯
怪我咯Original
2017-07-06 10:41:161926browse

This article mainly introduces the usage of php check date functioncheckdate. It analyzes the usage skills of checkdate function in php with examples. It is of great practical value. Friends who need it can refer to it.

The example in this article describes the usage of PHP check date function checkdate. Share it with everyone for your reference. The specific analysis is as follows:

You can use the checkdate function in php to verify the correctness of the date.

Grammar

integer checkdate (int %Month, int $Day, int $Year);

Demo code

<?PHP
echo "2/29/1900";
checkdate (2, 29, 1900)?print " is Valid":print " is not valid";
echo "\n";
echo "2/29/2000";
checkdate (2, 29, 2000)?print " is Valid":print " is not valid";
echo "\n";
echo "2/29/2100";
checkdate (2, 29, 2100)?print " is Valid":print " is not valid";
echo "\n";
echo "4/30/2008";
checkdate (4, 30, 2008)?print " is Valid":print " is not valid";
echo "\n";
echo "4/31/2008";
checkdate (4, 31, 2008)?print " is Valid":print " is not valid";
echo "\n";
?>

The output result is as follows

2/29/1900 is not valid
2/29/2000 is Valid
2/29/2100 is not valid
4/30/2008 is Valid
4/31/2008 is not valid

The above is the detailed content of How to use php checkdate() function to check the date. 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