Jump to content

Countdown Timer onyl displaying the days and second, not the minutes and hours


hms556

Recommended Posts

Javascript timer not displaying correctly. It has always displayed properly , but today out of nowhere its just not working  

the hours and the minutes are not working but  , the seconds are counting down. 

 

I am new to web development 

 

 

this is the    CDN and the external ref  to the countdown timer 

 

<script type="text/javascript" src= "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="countdown.jquery.js"></script> <!-- this is countdown timer script" <!-->
<script src="script.js"></script>      <!-- this is where countdown timer is refences and where i change the date" <!-->
 

below is the  <script src="countdown.jquery.js">

(function($){




$.fn.countdown = function(options){




var settings={'date':null};


if(options){


$.extend(settings,options);
}


this_sel= $(this);


function count_exec(){


eventDate=Date.parse( settings['date']) / 1000;


currentDate= Math.floor($.now()/1000);


seconds=eventDate -currentDate;


days = Math.floor(seconds / (60 * 60 * 24));
seconds -= days * 60 * 60 * 24;


hours = Math.floor(seconds / (60 * 60));
seconds -= hours * 60 * 60;


minutes = Math.floor(seconds/60);
seconds -= minutes * 60;


















this_sel.find('.days').text(days);
this_sel.find('.hours').text(hours);
this_sel.find('.mins').text(hours);
this_sel.find('.secs').text(seconds);








}




count_exec();


interval=setInterval(count_exec,1000);




}








}) (jQuery);

this is the jquery file   <script src="script.js"></script>

 

$(document).ready(function(){


$('#countdown').countdown({date: '26 January 2014 10:00:00'});




});
 

Problem appears in this section where hours is listed twice instead of minutes.

this_sel.find('.days').text(days);
this_sel.find('.hours').text(hours);
this_sel.find('.mins').text(hours);
this_sel.find('.secs').text(seconds);

should be:

this_sel.find('.days').text(days);
this_sel.find('.hours').text(hours);
this_sel.find('.mins').text(minutes);
this_sel.find('.secs').text(seconds);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.