I have user data stored in a database which includes $birthdate in a YYYY/MM/DD format, using Juma929's code as below:
Code: Select all
# $dob = strtotime($birthdate);
# $date_today = strtotime(date("Y/m/d"));
#
# $agex = $date_today - $dob;
#
# $years = floor($agex / 31556926);
# $remainder = $agex % 31556926;
# $months = floor($remainder / 2592000);
#
# echo $years . ' ' . $months;I'd just like some clues as to where its gone wrong or a prefered snippest of code to use.
Ive called the $birthdate info in my code
Code: Select all
$birthdate = mysql_query("SELECT birthdate FROM users WHERE id='$id'");
$birthdatearray = mysql_fetch_assoc($birthdate);
$dob = strtotime($birthdate);
$date_today = strtotime(date("Y/m/d"));
$agex = $date_today - $dob;
$years = floor($agex / 31556926);
$remainder = $agex % 31556926;
$months = floor($remainder / 2592000);
echo $years . ' ' . $months;