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

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

怪我咯
Release: 2023-03-12 21:16:02
Original
2008 people have browsed it

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);
Copy after login

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";
?>
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template