Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moment Timezone Works Locally, Not in Production #639

Closed
mackenzienolan opened this issue Jun 23, 2018 · 6 comments
Closed

Moment Timezone Works Locally, Not in Production #639

mackenzienolan opened this issue Jun 23, 2018 · 6 comments

Comments

@mackenzienolan
Copy link

For some reason when testing locally the below code returns correctly, however on dev or prod it returns as GMT.

Locally
moment().tz("America/Toronto").format() // 2018-06-22 00:00:00-04

Production
moment().tz("America/Toronto").format() // 2018-06-22 00:00:00+00

Does anyone know why this may be occurring?

@ellenaua
Copy link
Contributor

@mackenzienolan check please:

  • which version of moment-timezone is installed on prod
  • what is the value of moment().format() (without timezone change)

@mackenzienolan
Copy link
Author

Version: 0.5.14

Locally
moment().format() // 2018-06-22 00:00:00-04

Production
moment().format() // 2018-06-22 00:00:00+00

@mackenzienolan
Copy link
Author

I have been able to get it where it prints out correctly, except that it changes the offset and the time.

moment().startOf("day").tz("America/Toronto").format() // 2018-06-23 20:00:00-04

I've created a hack for now, but if anyone knows what I'm doing wrong that would be extremely helpful.

@marneborn
Copy link

marneborn commented May 10, 2019

I'm having the same problem. I've tracked down my issue to using moment@0.5.13 but there is a dependency that is using moment@0.5.25. Both use the same moment@2.18.0.

So when the dependency is loaded moment.tz is changed to be the 0.5.25 version.
This causes things to not work.

To reproduce

mkdir moment-tz-problem
cd moment-tz-problem
npm init --force
yarn add moment-timezone@0.5.13
yarn add ical-generator@1.7.1
yarn list v1.9.4
├─ ical-generator@1.7.1
│  ├─ moment-timezone@^0.5.25
│  └─ moment-timezone@0.5.25
│     └─ moment@>= 2.9.0
├─ moment-timezone@0.5.13
│  └─ moment@>= 2.9.0
└─ moment@2.24.0
$ node -e "const moment = require('moment-timezone'); console.log(moment().tz('US/Eastern').format('z'));"
EDT
$ node -e "require('ical-generator'); const moment = require('moment-timezone'); console.log(moment().tz('US/Eastern').format('z'));"
UTC

@GORA-SAG
Copy link

For the same code segment
moment().tz('Asia/Kolkata').format('z')
am getting IST locally but in prod getting UTC.

Am using version 0.5.28 any solution or workaround is available??

@gilmoreorless
Copy link
Member

This looks like a potential problem with dependency chains, which is very hard to debug. I suggest following the advice at #982 (comment) to resolve conflicts in dependency versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants