I am trying to add seven days to a Data object, however at some stage I start getting strange results.
var currDate = new Date(2011, 2, 28)
, oldTicks = currDate.getTime()
, newTicks = oldTicks + (86400000 * 7)
, nextWeek = new Date(newTicks)
console.log('Old ticks: ' + oldTicks)
console.log('New ticks: ' + newTicks)
console.log('New date : ' + nextWeek)
The output I get, both Chrome/FF is:
Old ticks: 1301230800000
New ticks: 1301835600000
log: New date : Sun Apr 03 2011 23:00:00 GMT+1000 (EST)
Expected to get:
log: New date : Mon Apr 04 2011 23:00:00 GMT+1000 (EST)
As you can see, instead of adding 7 days, just 6 were added. The code above, however, works fine with other dates, say 2011 Apr 28 or 2011 May 28.