PHP checkdate()函数与示例
PHP checkdate()函數(shù) (PHP checkdate() function)
checkdate() function is used to check the valid Gregorian dates. It accepts the date and returns Boolean values (True/False) based on the date values.
checkdate()函數(shù)用于檢查有效的公歷日期。 它接受日期,并根據(jù)日期值返回布爾值(真/假)。
Syntax:
句法:
checkdate(month,day,year);Parameter(s):
參數(shù):
month – It specifies the month in the numbers starting from 1 to 12.
month –以1到12之間的數(shù)字指定月份。
day – It specifies the day in the numbers starting from 1 to 31.
日期 –以1到31之間的數(shù)字指定日期。
year – It specifies the year in the numbers from 1 to 32767.
year –以1到32767之間的數(shù)字指定年份。
Return value:
返回值:
It returns "TRUE" – if the date is valid, else it returns "FALSE".
它返回“ TRUE” –如果日期有效,則返回“ FALSE”。
Example: PHP code to check whether given date is valid Gregorian date
示例:檢查給定日期是否有效的公歷日期PHP代碼
<?phpvar_dump(checkdate(12, 31, 2019)); //valid var_dump(checkdate(12, 31, -2018)); //invalid var_dump(checkdate(2, 29, 2019)); //invalid var_dump(checkdate(2, 29, 2020)); //valid//checking through conditions if (checkdate(12, 31, 2019)) echo "Valid\n"; else echo "Invalid\n";if (checkdate(12, 31, -2018)) echo "Valid\n"; else echo "Invalid\n";if (checkdate(2, 29, 2019)) echo "Valid\n"; else echo "Invalid\n";if (checkdate(2, 29, 2020)) echo "Valid\n"; else echo "Invalid\n"; ?>Output
輸出量
bool(true) bool(false) bool(false) bool(true) Valid Invalid Invalid ValidReference: PHP checkdate() function
參考: PHP checkdate()函數(shù)
翻譯自: https://www.includehelp.com/php/checkdate-function-with-example.aspx
總結(jié)
以上是生活随笔為你收集整理的PHP checkdate()函数与示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: set vector_Java Vect
- 下一篇: php 邮件验证_PHP程序来验证电子邮