0

I am using openweather map api for creating a weather application. The response data for daily has the following format:

{"dt":1590343200,"temp":302.72,..,..,}

It also provides timezone offset.

timezone_offset":19800

How do I calculate current date from the above 2 values using javascript ?

Thanks

Ashy Ashcsi
  • 1,529
  • 7
  • 22
  • 54
  • Does this answer your question? [Convert a Unix timestamp to time in JavaScript](https://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript) – Dionys May 24 '20 at 18:15
  • Is your question how to convert the time values to a Date, or how to use the offset appropriately? The former is answered by the duplicate, however if you're unsure of how to use the offset correctly, then it's not and the question can be reopened. – RobG May 25 '20 at 00:54

1 Answers1

0

Looks like a unix timestamp so:

const d = new Date((1590343200 - 19800) * 1000)
d.toGMTString() // "Sun, 24 May 2020 12:30:00 GMT"
Dionys
  • 3,083
  • 1
  • 19
  • 28