javascript - Remove '-' symbols when counting down from Java script code -


i using script work out hours mins , seconds date, fine past dates continues count up, when date in future - symbol attached front , don't want this, how prevent being applied

function uptime(countto) {       = new date();       difference = (now-countto);        days=math.floor(difference/(60*60*1000*24)*1);       years=math.floor(days/365);       hours=math.floor((difference%(60*60*1000*24))/(60*60*1000)*1);       mins=math.floor(((difference%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);       secs=math.floor((((difference%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);        //document.getelementbyid('years').firstchild.nodevalue = years;        document.getelementbyid('live-hour').innerhtml = hours;       document.getelementbyid('live-min').innerhtml = mins;       document.getelementbyid('live-sec').innerhtml = secs;        cleartimeout(uptime.to);       uptime.to=settimeout(function(){ uptime(countto); },1000); 

use math.abs absolute value of difference.

difference = math.abs(now-countto); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -