1

I have a unix timestamp and I want to convert it to a format like this 2018-09-01T12:06:54+0000

The closest I found is this way new Date(unix_timestamp).toISOString()

But, this prints it in the following manner 1970-01-18T04:14:15.076Z

How can I print it in the format mentioned above?

kosta
  • 4,302
  • 10
  • 50
  • 104
  • It's pretty strange, I done [this](https://stackoverflow.com/questions/12868176/convert-unix-timestamp-to-iso-8601) and it worked (read the first answer), may we see your unix_timestamp? – Margon Sep 06 '18 at 06:40
  • Sorry, I edited the question. Can I have the `+0000` instead of `Z`? – kosta Sep 06 '18 at 06:49
  • provide an example value for `unix_timestamp`, if it is in seconds, you need to multiply by 1000 because the Date contrusctor takes milliseconds as parameter: ex: `new Date(unix_timestamp_in_sec * 1000).` – sritmak Jun 23 '21 at 14:54

0 Answers0