The Calculate Age article isn't working.

Tim Edingfield

The article 


The JS code worked for a while, until suddenly it stopped. I am not sure if its because of a change in the way that the system pulls dates and calculations. But my colleague and I tried every basic debug step to figure out the issue. But to no avail.

When you put in a date: Example 07-02-2000, you get the result of -1979.

Now it used to work but for some reason now it isn't. Could someone help?

Follow 3 followers


Yuzo Arai 0 votes

Hello Tim!

I'm still looking into it, but when it gets to the date format conversion part of the today's date:

var today = new Date();
var _today = parseInt(today.getFullYear() + affixZero(today.getMonth() + 1) + affixZero(today.getDate()));

it looks like it's giving a weird value so the conversion is probably not working correctly.
It might be due to when getting today's date at

var today = new Date();

the date is not in the YYYY-MM-DD format so that might be the reason.
You might need figure out a way to get the date in that format which might solve the problem.

I hope that helps.

Comment actions Permalink