Get current date/time in seconds

前端 未结 13 1645
失恋的感觉
失恋的感觉 2020-11-29 17:14

How do I get the current date/time in seconds in Javascript?

13条回答
  •  天命终不由人
    2020-11-29 17:44

    To get today's total seconds of the day:

    getTodaysTotalSeconds(){
        let date = new Date();        
        return +(date.getHours() * 60 * 60) + (date.getMinutes() * 60) + date.getSeconds();
    }
    

    I have add + in return which return in int. This may help to other developers. :)

提交回复
热议问题