How can I convert a date into an integer?

后端 未结 4 1495
孤街浪徒
孤街浪徒 2021-02-02 05:48

I have an array of dates and have been using the map function to iterate through it, but I can\'t figure out the JavaScript code for converting them into integers.

This

4条回答
  •  醉话见心
    2021-02-02 06:10

    Using the builtin Date.parse function which accepts input in ISO8601 format and directly returns the desired integer return value:

    var dates_as_int = dates.map(Date.parse);
    

提交回复
热议问题