Home >Backend Development >PHP Tutorial >PHP check date function checkdate usage example, checkdate example_PHP tutorial
This article describes the use 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 results are 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
I hope this article will be helpful to everyone’s PHP programming design.