Home >Backend Development >PHP Tutorial >PHP check date function checkdate usage example_PHP tutorial
This article mainly introduces the usage of checkdate function in php. The example analyzes the usage skills of checkdate function in php, which is of great practical value. , friends in need can refer to it
The example in this article describes the usage of PHP checkdate 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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"; ?> |
1
2 3
6 7 816 17
|
<๐>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";<๐> <๐>?> |
1 2 3 4 5 | 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 |