How can I convert a date into an integer?

后端 未结 4 1496
孤街浪徒
孤街浪徒 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:09

    You can run it through Number()

    var myInt = Number(new Date(dates_as_int[0]));
    

    If the parameter is a Date object, the Number() function returns the number of milliseconds since midnight January 1, 1970 UTC.

    Use of Number()

提交回复
热议问题