I have an alert that will be triggered at exact 5:30 pm. I would like to make the date dynamic, I mean that it will get the system date. Because as you can see in my code, It only gets the time at the date I specify. Thanks!
function alert5pm() {
alert("It's already 5:30 pm and you only have 30 minutes left before to log-out");
}
var timeAt3pm = new Date("8/10/2012 05:30:00 PM").getTime()
, timeNow = new Date().getTime()
, offsetMillis = timeAt3pm - timeNow;
setTimeout('alert5pm()', offsetMillis);
For example:
Create an instance of the date to get the system date and time: var dateToday = new date();
from here, how can I extract an specific time. For example, I need to specifiy that I need to get the time 5:30pm at todays system date. Just like my code. But as you can see, It only gets the time at the date 8/10/2012. I want it to use the system date and time.
Any ideas?
Source:This SO Answer.