11 Feb
Age Calculator is a Wordpress plugin that provides a quicktag that will calculate the current age of a person/animal/whatever based on it’s birthdate. Supports changing the verbiage for year(s) and month(s) plus has a multiplier for animals (such as “in dog years”).
Using the quicktag [agecalc birthdate="1978-01-30] will display “31 years” using the default settings. Well, as long as it’s still 2009…
Visit the Age Calculator page at the WordPress Plugin Directory for more information.
13 Responses for "Wordpress Plugin: Age Calculator"
So, no info about you on the whole site?
You should check out the “About” page that’s linked up there in the top right-hand corner…
highly informative
G’day,
Great plugin, thank you.
BUG: all of the “ ” are missing a “;”. This breaks the plugin and displays “24 years” on the site. I have updated my version and it works great now.
FIX: replace all “ ” with “ ”
I look forward to seeing the update.
Thanks,
=-)
Crap – I fixed it. Added the “;” to the end of “ ”. Stupid error on my behalf…
Hi, great plugin, but I tried to use it to display the age og my 2 months old son. It insisted on 6 months for anything less than 6. Above 6 months, it started to show the right age.
Hi Josh,
There seems to be a bug at line 65 in your plugin
//Calculates Months
if ($bY == $cY)
{
<> $months = $cM – $bM;
if ($months == 0 || $months > 1)
{
This prevented the correct calculation of months.
regards,
Kjell
Hmm, that example code turned out a bit strange.
Anyway, this was the original line 65:
$months = $cM – $dM;
And this is what I think it should have been:
$months = $cM – $bM;
Kjell: Thank you – I’ve made the change to the source and uploaded to WordPress!
It would be cool if the plugin could show age in years, monts & days. So Josh is now 25 years, 3 months and 6 days old.
The month calculation doesn’t seem to be correct yet. It seems to be rounding upwards, but years calculation is fine. Vs Anton’s comment, I might suggest you let users specify the format the age is output in, such as %Y% years, %m% months, %d% days for Anton’s version, or %M% for total months (27 if 2 years 3 months) and %D% for total days. You could do lots with this, but it works great as is for the user I was looking for. Thank you!
Hi Josh, thank you for the plugin. I’m trying to hardcode the quicktag into php page (to use your plugin with Custom Fields) and it doesn’t work. Nor it works within post title. I guess, quicktags are not supposed to be placed in php, I’m new to php. Can your plugin be used within php, instead of quicktag? Thanks.
Yes, the plugin could be called directly from PHP although it would be difficult as it relies on many of the built-in functions of WordPress to function correctly.
Leave a reply