If $dob is a unix timestamp (as it is when you get it from the User Profile), this will calculate the age:
$age = intval(substr(date('Ymd') - date('Ymd', $dob), 0, -4));
If $dob is a string containing the date, use this:
$age = intval(substr(date('Ymd') - date('Ymd', strtotime($dob)), 0, -4));
Or, a more generic version:
if (is_string($dob)) {
$age = intval(substr(date('Ymd') - date('Ymd', strtotime($dob)), 0, -4));
} else {
$age = intval(substr(date('Ymd') - date('Ymd', $dob), 0, -4));
}
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
[ed. note: BobRay last edited this post 14 years, 2 months ago.]