convert iso date to milliseconds in javascript

后端 未结 10 1976
不知归路
不知归路 2020-11-29 00:40

Can I convert iso date to milliseconds? for example I want to convert this iso

2012-02-10T13:19:11+0000

to milliseconds.

Because I

10条回答
  •  忘掉有多难
    2020-11-29 01:30

    A shorthand of the previous solutions is

    var myDate = +new Date("2012-02-10T13:19:11+0000");
    

    It does an on the fly type conversion and directly outputs date in millisecond format.

    Another way is also using parse method of Date util which only outputs EPOCH time in milliseconds.

    var myDate = Date.parse("2012-02-10T13:19:11+0000");
    

提交回复
热议问题