Hi there,
Can anyone inform me of the best way to get the current date/time in seconds in javascript?
Hi there,
Can anyone inform me of the best way to get the current date/time in seconds in javascript?
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");
}
var seconds = new Date().getTime() / 1000;
....will give you the seconds since mindnight, 1 Jan 1970
To get the number of seconds from the Javascript epoch use:
date = new Date();
milliseconds = date.getTime();
seconds = milliseconds / 1000;