Reputation: 1237
i am tryin to find differnce in current time and date of birth can anyone help me
to find the age from an mysql query in zend framwork the age should be greater than 21
$date = Zend_Date::now();
$dob = $post['dob'];
$age = $date ->sub($dob);
$age->toString(Y);
can this work anyone know any simple method thanks for helping
Upvotes: 0
Views: 548
Reputation: 434
What about extracting years from database. If you using mysql, try to use this query
SELECT DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(dob)), '%Y')+0 AS age FROM people;
It’ll also work with pre and post-epoch dates.
If this method will not solve your problem, try to read about Zend_Date comparison
but instead of
if ($date->compare(10, Zend_Date::MINUTE) == -1)
use
if ($date->compare(21, Zend_Date::YEAR) == -1)
Upvotes: 3