Search code examples
javascriptgoogle-apitimestamprfc3339

Converting time-stamp to milliseconds in javascript


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


Solution

  • 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.