Birthday Calendar - Help with age display

By: Erik Meeder | Asked: 04/16/2025
ForumsCategory: General questionsBirthday Calendar - Help with age display
Erik Meeder asked 1 month ago

I am struggling with creating a simple birthday calendar. that will accurately say the age of the person. trying to avoid custom php especially if there (hopefully) is a built in solution.

I have about 200 names plotted on the calendar view so far. 

Right now where I am at is that it displays the persons Current Age. This is based on the their date of birth in a date field [45] and then the automatic AGE calculator (field [60]). I have added a hidden drop down with the Yearly (+1 year) option so that the birthday will display every year on the calendar. 

i want it to say something like "John is 36 today!"

Can this be done? possibly with the [x time_ago=1] function? I have tried a few different things, but it seems to not use my DoB field as a date field.  i tried [45 time_ago=y] with no luck.

Is there a built in solution for this? Anyone have any suggestions?

Thanks

 

 

2 Answers
Rob LeVineRob LeVine Staff answered 1 month ago

I just tried using a date field and the time_ago="y" attribute and it worked fine for me. When you say, "but it seems to not use my DoB field as a date field", are you sure the field is a date field? If it is, is it a simple date field or does it have advanced features on it. Maybe try the same thing with a plain date field and you can even seed it with a value, just to make sure.

Erik Meeder replied 1 month ago

i noticed that the code works in Detail page but the exact same code doesn't return anything on the Listing page. I am using the Calendar View.
The best i could do to make show the correct age for the upcoming birthday is something like this.

[45 offset="-11 months" time_ago=y] ([45] is my Date field)

I'm assuming that as soon as the current time is 11 months from the next birthday it will hopefully display the upcoming birthday age correctly.

Does it make sense that this same code will not work on the listing page?

Rob LeVineRob LeVine Staff replied 1 month ago

It doesn't make sense to me, so I suggest removing variables. Make a new view that is just a simple view, i.e., not a Calendar view and see if you have the same problem. Keep iterating over issues until you narrow it down. Once you find the root of the issue, you can contact Strategy 11 support. Maybe you found a bug.

Charl Van Niekerk replied 2 weeks ago

Hi Erik, Im working on a similar project, how did you manage to display the birthdays for every year, can you perhaps explain in detail?

Erik Meeder replied 2 weeks ago

Hi Charl.
I am using a very basic calculation in my view. It is working for now but I'm sure there is a more accurate method.
My date of birth field is [45]
Then in my calendar view i entered this.

[45 offset="-11 months" time_ago=y]

So this will display the correct age that the person is turning 11 months before their birthday. So there is a but of a limitation if for instance someone scrolls ahead in the calendar to their birthday next year (more then 11 months away). Then the age they are turning will not be correct.

For now this is sufficient for what i am doing.

Since then i have added fields (admin visible only) in my form that breaks down the date of birth into 3 fields for day, month, and year (using Javascript). I think using that there might be other options, but for now I'm good with my current method.

Charl Van Niekerk answered 2 weeks ago

Hi Erik, much appreciated for your response.I understand - I also ran into those problems, decided to go the JavaScript route, please see attached end result - still tinkering with the code..I show all my birthdays in current year and locked it, so person dont have to go next or previous year or to the year 2000 for example.Much appreciated 

Attachments

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right