Converting a string formatted YYYYMMDDHHMMSS into a JavaScript Date object

后端 未结 6 666
借酒劲吻你
借酒劲吻你 2021-01-06 02:33

I have a string with a date in it formatted like so: YYYYMMDDHHMMSS. I was wondering how I would convert it into a JavaScript Date object with JavaScript.

Thanks in

6条回答
  •  爱一瞬间的悲伤
    2021-01-06 02:57

    I find DateJS the best library for anything that has to do with converting, parsing and using dates in JavaScript. If you need that kind of conversions more often you should really consider using it in your application:

    Date.parseExact("20091202051200", "YYYYMMDDHHMMSS");
    

提交回复
热议问题