asp.net mvc 4 - How to show event Timer in mvc using javascript -


i developing appointment schedule application ,i need timer each appointment event using full calendar. want show event timer can enable/disable call button per timer.

plz help? thanx in advance.

try code

set current date

timezoneinfo timezoneinfo =   timezoneinfo.findsystemtimezonebyid("timezonename");   var d = new date('@datetime.utcnow.totimezonetime(timezoneinfo)'); 

calculate remaining time

function gettimeremaining(endtime){         var t = date.parse(endtime) - date.parse(d);         var seconds = math.floor( (t/1000) % 60 );         var minutes = math.floor( (t/1000/60) % 60 );         var hours = math.floor( (t/(1000*60*60)) % 24 );         var days = math.floor( t/(1000*60*60*24) );         return {             'total': t,             'days': days,             'hours': hours,             'minutes': minutes,             'seconds': seconds         };     }      var timeinterval; 

initilize clock

var timeinterval;     function initializeclock(endtime){         var clock = document.getelementbyid(id);         timeinterval = setinterval(function(){             var t = gettimeremaining(endtime);             if(t.total<0)             {                 t.seconds =((-1)*parseint(t.seconds))-1;                 t.minutes = ((-1)*parseint(t.minutes))-1;                 t.hours = ((-1)*parseint(t.hours))-1;                 t.days =  ((-1)*parseint(t.days))-1;             }              t.days= t.days<=9?'0'+t.days:t.days             t.hours= t.hours<=9?'0'+t.hours:t.hours             t.minutes= t.minutes<=9?'0'+t.minutes:t.minutes             t.seconds= t.seconds<=9?'0'+t.seconds:t.seconds               var text=(t.days>0)?t.days  + ' d ':'';              if(t.total<=0){                      text='started '                     text+=(t.days>0)?t.days  + ' d ':'';                     text+=(t.hours>0) || (t.days>0)?t.hours  + ' h ':'';                     text+=(t.minutes>0) || (t.hours>0)?t.minutes  + ' m ':'';                     text+=(t.seconds>0) || (t.minutes>0)?t.seconds  + ' s ago ':'';              }             else{                  text+=(t.hours>0) || (t.days>0)?t.hours  + ' h ':'';                 text+=(t.minutes>0) || (t.hours>0)?t.minutes  + ' m ':'';                 text+=(t.seconds>0) || (t.minutes>0)?t.seconds  + ' s left ':'';             }             clock.text(text);         },1000);     }