i have have issues javascript below. trying countdown clock done, result getting off i.e. below due time of 1900 hrs today
gives 11:44:00 left when current time 17:16:00. should 1 hour , 44 minutes. adding 10 hours somewhere.
any ideas on went wrong have rewritten same result. know not clean code yet. prototyping atm.
regards,
var countdownduetime = new date('september 26, 2015 19:00:00') function updateclock() { var currenttime = new date(); var currenthours = currenttime.gethours(); var currentminutes = currenttime.getminutes(); var currentseconds = currenttime.getseconds(); //pad time make 2 digit minutes , seconds currentminutes = (currentminutes < 10 ? "0" : "" ) + currentminutes; currentseconds = (currentseconds < 10 ? "0" : "" ) + currentseconds; var currenttimestring = currenthours + ":" + currentminutes + ":" + currentseconds; $("#clock").html(currenttimestring); countdown(currenttime); } function countdown(currenttime) { var difference = new date(countdownduetime - currenttime); var currenthours = difference.gethours(); var currentminutes = difference.getminutes(); var currentseconds = difference.getseconds(); //pad time make 2 digit minutes , seconds currentminutes = (currentminutes < 10 ? "0" : "" ) + currentminutes; currentseconds = (currentseconds < 10 ? "0" : "" ) + currentseconds; var currenttimestring = currenthours + ":" + currentminutes + ":" + currentseconds; $("#countdown").html(currenttimestring); } $(document).ready(function() { setinterval('updateclock()', 1000); })
Comments
Post a Comment