javascript - Jquery: time counter until the register will be open -
i need create simple time counter until register open.
i have create karate class on each sunday @ 13:00
now want allow users register class 11:00
when counter hits time set ( example 11:00) timer disappear , action (like register button show).
i need server time (it can done php).
var date = new date("<?php echo date("y-m-d h:i:s"); ?>");
now need create time counter show hourse , minuts left untile 11:00 form server time (when user hit webpage).
for example:
if server time 10:42 counter show 18 minuts , 00 seconds left. , counter start counting time down.
you may try option, can have timer function below:
function timer(till, ontimerelapsed) { var = new date(); if (from < till){ console.log(from); settimeout(function() { timer(till, ontimerelapsed); }, 1000); return false; } ontimerelapsed() return true; }
you can invoke on page load passing time (date) @ want timer elapsed. ex: elapse timer after 1 min current time:
var till = new date((new date()).gettime() + 1000*60); timer(till, function(){alert('timer elapsed');});
in place of alert in callback can have code register.
Comments
Post a Comment