更新时间:2021-07-25 05:31:46
您可以初始化Date对象并调用getTime()以unix形式获取它。它以毫秒为单位,因此您需要除以1000才能在几秒钟内得到它。
You can initialise a Date object and call getTime() to get it in unix form. It comes out in milliseconds so you'll need to divide by 1000 to get it in seconds.
(new Date("2013/09/05 15:34:00").getTime()/1000)
它可能有小数位,所以将它包装在Math.round中就可以清除它。
It may have decimal bits so wrapping it in Math.round would clean that.
Math.round(new Date("2013/09/05 15:34:00").getTime()/1000)