我必须开发一个表格,该表格可以记录用户年龄并计算年龄,如果超过 18 岁,则将他带到注册表格
hi i have to develop a form which takes user age and calculates age and if over 18 procedds to take him to registeration form
我的问题是我正在使用 zend 框架如何实现它,当它不应该与模型进行太多交互并且数据库中没有数据时
my question is has i am using zend framework how to implement it when its not supposed to interact with model much and their is no data in database
如何验证人的年龄
我正在尝试使用此代码
$data = array ( 'dob' => date ( "Y-m-d" ));
$select = $db
->select()
->from('data', array(
'id',
'age' => new Zend_Db_Expr("DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(dob)), '%Y')+0")))
我可以使用数组吗?请帮我朋友秀应该是这个查询
can i use an array ? please help me friendshow should be this query
我不太明白您的问题...您是否在根据出生日期计算年龄时遇到问题?
I don't quite understand your question... Are you having trouble calculating the age from a DOB?
如果是这样,这应该可以解决您的问题:
If so, this should take care of your problem:
function Age($date = 'now')
{
return intval(substr(date('Ymd') - date('Ymd', strtotime($date)), 0, -4));
}
var_dump(Age('1975-04-25')); // int(36)
if (Age('1975-04-25') >= 18)
{
// proceed to registration
}
这篇关于在注册用户之前验证年龄以使用 mvc 检查他是否超过特定年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!