0

I have a date which is of format 20170622T164322Z. How to convert it into milliseconds(epoch time) in javascript. I am new to javascript, kindly help

Virat
  • 551
  • 4
  • 9
  • 23
  • You do notice that this timestamp has no milliseconds in it, don't you? 2017/06/22 at 16:43:22 + timezone. No milliseconds. – sjahan Jun 22 '17 at 11:39
  • I framed the question in a wrong way. Please refer the edit – Virat Jun 22 '17 at 11:40
  • Do you mean extract or convert? You do use both verbs in your question though they are no synonyms. – getjackx Jun 22 '17 at 11:41
  • I think this is what you are looking for: https://stackoverflow.com/questions/11318634/how-to-convert-date-in-rfc-3339-to-the-javascript-date-objectmilliseconds-since – yuriy636 Jun 22 '17 at 11:41
  • @yuriy636 I did refer it, but my format is different from, what they have used – Virat Jun 22 '17 at 11:42

1 Answers1

2

If you could use moment.js in your project, you can do this:

moment("20170622T164322Z").unix()

Example running on the console of the browser:

moment("20170622T164322Z").unix()
1498149802

Btw, moment.js is just great when dealing with date time.

Dat Nguyen
  • 1,626
  • 22
  • 25