I'm trying to use the pattern described here: How to add number of days to today's date?
My goal is to start an animation at a date one week before a certain event, in this case the launch of Sputnik. My code is:
var SputnikLaunchDate = new Date(1957, 9, 4); //The first event of insterest in the simulation.
var earliestAnimationDate = new Date();
earliestAnimationDate.setDate(SputnikLaunchDate.getDate() - 7); //Start 1 week before then
When I do this in the Firefox debugger, the variable SputnikLauchDate is correct (1957-10-04T05:00:00.000Z). However, earliestAnimationDate ends up being 2015-05-28T18:49:54.313Z and I have no idea why. Can someone explain to me what I'm doing wrong?