$strSystemMaxDate = (date('Y') - 15).'/'.date('m/d');
if(strtotime($strDateOfBirth) > strtotime($strSystemMaxDate))
{
$arrErrors[] = _("Minimum age is 15 years.");
$blnValidated = false;
}
you have to first convert your input date in yyyy-mm-dd frormate.you can not directly put validatation. you have to convert your date into timestamp and then after you have to check validation.
$strSystemMaxDate = (date('Y') - 15).'/'.date('m/d');
if(strtotime($strDateOfBirth) > strtotime($strSystemMaxDate))
{
$arrErrors[] = _("Minimum age is 15 years.");
$blnValidated = false;
}
发布评论
评论(3)
PHP 函数
checkdate
就是您要寻找的。The PHP function
checkdate
is what you're looking for.您必须首先将输入日期转换为 yyyy-mm-dd 形式。您不能直接进行验证。您必须将日期转换为时间戳,然后必须检查验证。
you have to first convert your input date in yyyy-mm-dd frormate.you can not directly put validatation. you have to convert your date into timestamp and then after you have to check validation.
年龄也不是太难:
Age is not too hard too: