Git Product home page Git Product logo

Comments (4)

dimfu avatar dimfu commented on September 26, 2024 1

I now understand that the problem I encountered was not caused by the moment-timezone library. After conducting a thorough investigation, I came to the realization that the root cause was a silly error. This API was responsible for retrieving the timezone name, but it was returning a 400 error due to an incorrect API key in production. I apologize for any misunderstanding and for taking up your valuable time on this matter.

from moment-timezone.

gilmoreorless avatar gilmoreorless commented on September 26, 2024

Your prod environment is reporting its time zone as UTC, and the resulting call to moment.tz().format() is also returning in UTC. I wonder if there's a problem loading the data for Moment Timezone in the prod environment.

It's hard to diagnose a problem like this without knowing the project details, but here are some things you could look into:

  1. Is the data definitely loading in prod? Try other time zones as well. If they all produce UTC time, the data might not be loading correctly.
  2. Are you using moment-timezone on the server in something like NodeJS, or in the browser? The data loading path can be different between them.
  3. Are you using any kind of framework or bundling tool? They can sometimes mess up the loading of other modules or JSON files.

from moment-timezone.

dimfu avatar dimfu commented on September 26, 2024

I am indeed using moment-timezone on the server as a pre-build script that generate JSON file for my Next JS application deployed on Vercel, if you interested on looking here is the code for it. Currently I had to run the script locally to get the correct time.

If you have any suggestions or advice on how I could run the script on the server and get the correct time, I would greatly appreciate it. Thank you.

from moment-timezone.

gilmoreorless avatar gilmoreorless commented on September 26, 2024

Hmmm, I'm not really familiar with Vercel's specific setup. But I do know that most of these code platforms will default the servers to UTC, and possibly allow setting a TZ environment variable to change the server's time zone.

I think the bigger question is why parsing a date as being in America/Los_Angeles returns the Z indicator for UTC when it's formatted. To me that looks like the time zone data file hasn't loaded correctly. Are you able to check the logs for a message like Moment Timezone has no data for America/Los_Angeles?

from moment-timezone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.