regoch Posted May 28, 2012 Share Posted May 28, 2012 I got mysql with list if people and one of field in base is date of birth in date format. So I have two questions. 1. Hot to get poeple age from date of brith field? 2. How to get all people that are younger then 45 years. Quote Link to comment https://forums.phpfreaks.com/topic/263285-get-age-from-date-of-birth/ Share on other sites More sharing options...
livethedead Posted May 28, 2012 Share Posted May 28, 2012 Pretty simple queries.. http://php.net/manual/en/function.date.php Quote Link to comment https://forums.phpfreaks.com/topic/263285-get-age-from-date-of-birth/#findComment-1349328 Share on other sites More sharing options...
dyr Posted May 28, 2012 Share Posted May 28, 2012 To get the date of birth I usually make the simple function: function getAge( $p_strDate ) { list($Y,$m,$d) = explode("-",$p_strDate); return( date("md") < $m.$d ? date("Y")-$Y-1 : date("Y")-$Y ); } Quote Link to comment https://forums.phpfreaks.com/topic/263285-get-age-from-date-of-birth/#findComment-1349329 Share on other sites More sharing options...
regoch Posted May 28, 2012 Author Share Posted May 28, 2012 gonna try, thanks for help! Quote Link to comment https://forums.phpfreaks.com/topic/263285-get-age-from-date-of-birth/#findComment-1349336 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.