- script will start on exact time (ex: 2015:06:15:00:00)
- If its on time, it will alert HELLO every 1 second.
setInterval(function () {alert("Hello")}, 1000);
could you please help me how to make this on up?
setInterval(function () {alert("Hello")}, 1000);
could you please help me how to make this on up?
There is no possibility to define a date driven trigger in javascript.
Instead you might register your function from the beginning and check there if the start date is reached.
<html>
<head>
<script type="text/javascript">
var startDate = new Date("2015-06-14 12:47");
window.setInterval(checkDate, 1000);
function checkDate()
{
if (new Date() > startDate)
myDate.value = new Date().toLocaleString(); //or do your alert ;)
}
</script>
</head>
<body>
<input type="text" id="myDate" style="width: 200px" />
</body>
</html>
I believe I have the time set right in this JSFiddle