PHP 怎么样判断输入的是否是日期格式

来源:百度知道 编辑:UC知道 时间:2024/05/09 13:52:34
ASP 和VB 用ISDATE()函数来判断 请问PHP 用什么函数判断 CHECKDATE()函数好象不行

bool checkdate ( int month, int day, int year )
如果给出的日期有效则返回 TRUE,否则返回 FALSE。检查由参数构成的日期的合法性。日期在以下情况下被认为有效:
year 的值是从 1 到 32767
month 的值是从 1 到 12
Day 的值在给定的 month 所应该具有的天数范围之内,闰年已经考虑进去了。

int strtotime ( string time [, int now] )
本函数预期接受一个包含美国英语日期格式的字符串并尝试将其解析为 Unix 时间戳(自 January 1 1970 00:00:00 GMT 起的秒数)
例子:
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";

如果不行 你自己写 正则表达式。