John Dawyers John Dawyers - 1 year ago 55
Node.js Question

NodeJS date is different on Cloud Server vs Local

I am using Google Cloud for NodeJS applications (new to this). I use node to scrape dates from a website and then create date objects like so

var date = new Date("06/08/2016");

When I run the app on my local server the date is correct. When I push it to Google Cloud the date is one day behind. Does anyone have any insight into why this might be happening? I scrape the date as text in the format MM/DD/YYYY.

Answer Source

The time zone of your server is probably different than your time zone. You can check by checking the Date object via (new Date()).getTimezoneOffset()