Trying to print a time from my node application on a heroku server. The times printing out aren't matching up...
It's a 6 hour difference (we're in GMT-6) so it would make sense that it's a timezome issue. However, I'm conflicted because the dates printed are created in the format:
var time = (new Date('2012', '12', '10')).valueOf();
console.log(time);
Gives 1355097600000 instead of 1355119200000.
Staticly created dates should always be static right? No matter what timezone you're in, the beginning of 2012/12/10 should be the same length from 1970/01/01.
Javascript creates dates based on the time zone of the browser or node server. To get a static date, you need to pass in the timezone you want the date created in. Examples:
var time = (new Date('December, 2012 12:00:00 pm GMT')).valueOf();
console.log(time)
returns
1354363200000
My timezone is PST, so if I do
var time = (new Date('December, 2012 12:00:00 pm PST')).valueOf();
console.log(time)
It returns the same value (1354392000000) as if I'd done
var time = (new Date('December, 2012 12:00:00 pm')).valueOf();
console.log(time)