Note that there are some explanatory texts on larger screens.

plurals
  1. POCountdown timer, need to convert days to hours
    primarykey
    data
    text
    <p>I have a countdown timer with days, hours, minutes and seconds. I want to remove days. Need to convert days to hours.</p> <p>I tried to do it by myself, but no success because of lack of knowledge. </p> <pre><code> (function(){ $.fn.lofCountDown = function( options ) { return this.each(function() { // get instance of the lofCountDown. new $.lofCountDown( this, options ); }); } $.lofCountDown = function( obj, options ){ this.options = $.extend({ autoStart : true, LeadingZero:true, DisplayFormat:"&lt;div&gt;%%D%% Days&lt;/div&gt;&lt;div&gt;%%H%% Hours&lt;/div&gt;&lt;div&gt;%%M%% Minutes&lt;/div&gt;&lt;div&gt;%%S%% Seconds&lt;/div&gt;", FinishMessage:"Expired", CountActive:true, TargetDate:null }, options || {} ); if( this.options.TargetDate == null || this.options.TargetDate == '' ){ return ; } this.timer = null; this.element = obj; this.CountStepper = -1; this.CountStepper = Math.ceil(this.CountStepper); this.SetTimeOutPeriod = (Math.abs(this.CountStepper)-1)*1000 + 990; var dthen = new Date(this.options.TargetDate); var dnow = new Date(); if( this.CountStepper &gt; 0 ) { ddiff = new Date(dnow-dthen); } else { ddiff = new Date(dthen-dnow); } gsecs = Math.floor(ddiff.valueOf()/1000); this.CountBack(gsecs, this); }; $.lofCountDown.fn = $.lofCountDown.prototype; $.lofCountDown.fn.extend = $.lofCountDown.extend = $.extend; $.lofCountDown.fn.extend({ calculateDate:function( secs, num1, num2 ){ var s = ((Math.floor(secs/num1))%num2).toString(); if ( this.options.LeadingZero &amp;&amp; s.length &lt; 2) { s = "0" + s; } return "&lt;b&gt;" + s + "&lt;/b&gt;"; }, CountBack:function( secs, self ){ if (secs &lt; 0) { self.element.innerHTML = '&lt;div class="lof-labelexpired"&gt; '+self.options.FinishMessage+"&lt;/div&gt;"; return; } clearInterval(self.timer); DisplayStr = self.options.DisplayFormat.replace(/%%D%%/g, self.calculateDate( secs,86400,100000) ); DisplayStr = DisplayStr.replace(/%%H%%/g, self.calculateDate(secs,3600,24)); DisplayStr = DisplayStr.replace(/%%M%%/g, self.calculateDate(secs,60,60)); DisplayStr = DisplayStr.replace(/%%S%%/g, self.calculateDate(secs,1,60)); self.element.innerHTML = DisplayStr; if (self.options.CountActive) { self.timer = null; self.timer = setTimeout( function(){ self.CountBack((secs+self.CountStepper),self); },( self.SetTimeOutPeriod ) ); } } }) })(jQuery) </code></pre> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload