0

I am using openweathermap API, I am trying to fetch the timezone. The api have timezone as: 34200. How can I convert it to date format? I am using javascript. I am new to it, so I am not sure where to start. I even looked up, but couldn't find any solutions.

  • 1
    What "date format" do you want? If it's a timezone offset, it should be displayed as something like ±H:mm or ±HHmm. [*JavaScript seconds to time string with format hh:mm:ss*](https://stackoverflow.com/questions/6312993/javascript-seconds-to-time-string-with-format-hhmmss) should help. – RobG Jun 21 '20 at 20:24
  • +1 to Rob. You'll need to explain the format you want. Also, OpenWeather's APIs are not all the same. When calling an API like [this one that gets the *current* weather](https://openweathermap.org/current), the `timezone` field represents the *current* offset from UTC for that location. However, their ["One Call API"](https://openweathermap.org/api/one-call-api) returns both the current offset (in the `timezone_offset` field) as well as an IANA time zone identifier (in the `timezone` field). You can use the latter to get the offset for *any* point in time, not just the current one. – Matt Johnson-Pint Jun 22 '20 at 16:37

2 Answers2

0

It's how much the time has shifted in seconds from the UTC, so 34200 means 9,5 hours to the east. So this one would probably be somewhere in china. If you need help with the code, just say so, I can help you with the code too. But I think this answers your question

Oliver Hnat
  • 797
  • 4
  • 19
-1

You can use moment library for convert time or date. It is very easy to understand and implement.

Savan
  • 102
  • 6