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… Oh, you’ll need to remove the spaces after the “[" and before the "]“.
Visit the Age Calculator page at the WordPress Plugin Directory for more information.
Testing…
[ agecalc birthdate="1978/01/30" ] => 34 years
20 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.
Hi! I think your plugin is a great idea, but although simple as it seems to use, I can´t get a result in my page. I´m using WP 2.9.2. There is an incompatibility issue with that version? I made a single page in WP with this text:
Mi name is Alex and I am [agecalc *birthdate="1978-01-30"* year="" years="" multipliery="" month="" months="" multiplierm=""] years old.
I´d really appreciate if you or anyone can give me a hint, thanks in advance!
I must say I already made a test without aditional parameters and without asterisks:
Mi name is Alex and I am [agecalc birthdate="1978-01-30"] years old.
but this didn´t work either. In both cases, I don´t get any error messages, but just no output.
Thanks again.
Alex: That’s very strange, I have it running on several other sites running 2.9.2… Try replacing the hypens with slashes and see what happens:
[agecalc birthdate="1978/01/30"]
I’m curious to see what happens. I’ve added it to this post as a test too…
Hi Josh… I’ve read this twice and I still don’t get it! The post on backing databases was good though, cheers!
Now, how old is my pet (her name is Zulu) in chimp years?
how can i display age calculator im my sites page or in a post?
Age Calculator will work on both pages and posts as it uses standard WordPress shortcode functionality.
hi josh,
could it show age in years, months & days
thx
Leave a reply