-1

I have timestamp and want to convert it to DateTime. How can I do this in JS? i.e. Timestamp -

59080993

Want result as -

2016-05-30T12:10:30.407+05:30

Parita Porwal
  • 170
  • 1
  • 3
  • 15
  • using moment.js, you can convert timesetamp to any given format, var time = moment(1382086394000).format("DD-MM-YYYY h:mm:ss"); will print 18-10-2013 11:53:14; – Sugam Jun 07 '16 at 12:33
  • 1
    Refer [this](http://stackoverflow.com/questions/19485353/function-to-convert-timestamp-to-human-date-in-javascript) – Nitesh Goyal Jun 07 '16 at 12:34
  • alert(new Date(1291656749000)).toUTCString() – Sumanta736 Jun 07 '16 at 12:34
  • Also see [*How to format a JavaScript date*](http://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date?s=1|6.0660). – RobG Jun 07 '16 at 13:07

2 Answers2

4

new Date(timestamp).toISOString()

Parita Porwal
  • 170
  • 1
  • 3
  • 15
  • It's good that you have answered this yourself, but it's a good idea to search answers for such basic questions without SO and post here only when you can't find an answer. This is why some people have already voted down the question. – YakovL Jun 07 '16 at 12:38
  • Code–only answers are not helpful. *toISOString* is always UTC/GMT, the OP seems to want some other time zone. – RobG Jun 07 '16 at 13:07
0

I guess your timestamp is wrong. Because:

`new Date(59080993) //=> Thu Jan 01 1970 18:24:40 GMT+0200`
Roman Koliada
  • 2,972
  • 1
  • 16
  • 48