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
Asked
Active
Viewed 135 times
0

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 Answers
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
-
I just did. I think it wasn't well worded before, that's why people give -1 – Dat Nguyen Jun 23 '17 at 07:57
-
Also, if my answer does address your question, please consider accept it as a correct answer. Thanks! – Dat Nguyen Jun 23 '17 at 08:22