After a deeper inspection of your code, here's your mistake:
var ageDate = new Date(ageDifMs);
The point is: never create a Date
object out of a difference of dates, because it would make no sense. What you get is a Date
object that represents the instant ageDifMs
milliseconds after January 1st, 1970 UTC, and that's what methods like getMonth
, getDate
, getHours
and so on refer to.
So, you got a date like March 28th, 1970 and that's when the Daylight Saving Time happens.
If you want to know the difference of two dates in terms of months and days and so on, you either can compute the differences of the results of getMonth
and the other methods, or fix the length of a year, a month and compute the single values using modulus and divisions.
Also, you would rather use setInterval
instead of setTimeout
for timed continuous tasks.