1
votes

I am running an node js - express api using moment.js. My current TZ-Location is Europe/Berlin.(local) I had a inkonsistent state between my develop environment(local) and my production environment. While using the moment library in develop/local environment ive got an utc offset of 120min. But the Google Cloud standard AppEngine doesnt have an offset. So I get a date, which is 2h lower than needed. I was seaching for a while but dont found the right answer to set the local timezone or a local offset for the appengine to work with.

Does someone know, how to fix this problem globaly without changing all date-parsing statements? --> moment()

2

2 Answers

0
votes

You can use global instance and change tz using moment.tz

More: https://momentjscom.readthedocs.io/en/latest/moment-timezone/01-using-timezones/05-default-timezone/

moment.tz.setDefault("Europe/Berlin");

Also can see list of TZ:

How to get list of all timezones in javascript

0
votes

If you want to set the timezone globally for moment you can do that by

const moment = require('moment-timezone')

moment.tz.setDefault('Europe/Berlin')

https://momentjscom.readthedocs.io/en/latest/moment/03-manipulating/09-utc-offset/