Get current date/time in seconds

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

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

13条回答
  •  一个人的身影
    2020-11-29 17:44

    You can met another way to get time in seconds/milliseconds since 1 Jan 1970:

    var milliseconds = +new Date;        
    var seconds = milliseconds / 1000;
    

    But be careful with such approach, cause it might be tricky to read and understand it.

提交回复
热议问题