Get current date/time in seconds

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

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

13条回答
  •  旧巷少年郎
    2020-11-29 17:41

    Based on your comment, I think you're looking for something like this:

    var timeout = new Date().getTime() + 15*60*1000; //add 15 minutes;
    

    Then in your check, you're checking:

    if(new Date().getTime() > timeout) {
      alert("Session has expired");
    }
    

提交回复
热议问题