I have a portion of script that calculates the days remaining to an event:
var currTime = Math.round(new Date().getTime() / 1000.0);
var dispDate = event.find('UnixEpoch').text();
var diffDate = (dispDate - currTime) / 86400;
var dateRound = Math.round(diffDate) - 30;
The first line gets the current Unix Epoch time and shaves off the milliseconds. The second line gets the future event date from an XML feed. If I put both times into an Epoch calculator online, I get the correct date for both currTime and dispDate. But when I divide them down to days (third line), the end result is off by more than 30 days, requiring that I use the last line to get the right number of days.
Now, that's strange enough. But there's something else going on that I can't figure out. It used to be off by 31 days, and now that's wrong, so I altered the script to 30 days, which is right.
Can anyone point out what I'm doing wrong? I can't for the life of me figure out why this is happening, and I'd rather not have to keep tweaking it.