Closed Thread
Thread Tools Search this Thread
Unread 10th Mar 2014, 12:08 AM   #1
Active Warrior
 
marioxiao's Avatar
 
Join Date: 2008
Location: Stoneville
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts
Default
Ask Countdown Timer
Share on: 
fb share twitter share gplus share more share

I am creating countdown timer for 70 seconds before the download link is appear
I want it appear like 1:10 rather than 70 seconds, how to do that ?

preview :
Countdown Timer

this is the script I am using :

<script type="text/javascript">
jQuery(document).ready(function() {
var sec = 70
var timer = setInterval(function() {
$("#mdtimer span").text(sec--);
if (sec == 0) {
$("#makingdifferenttimer").delay(1000).fadeIn(1000 );
$("#mdtimer").hide(1000) .fadeOut(fast);}
},1000);
});
</script>

<center>
<a class="button" href="http://www.downloadlink.com/" id="makingdifferenttimer" rel="nofollow" style="display: none;" rel="nofollow" target="_blank">Download</a>
</center>

<div id="mdtimer">
<div style="font-size: large; text-align: center;">
<b>Please Wait <span>70</span> seconds</b></div>
</div>

marioxiao is offline  
Unread 10th Mar 2014, 12:51 AM   #2
Share and care.
War Room Member
 
BinaryKing's Avatar
 
Join Date: 2013
Location: Germany
Posts: 48
Thanks: 9
Thanked 57 Times in 12 Posts
Default
Re: Ask Countdown Timer
Share on: 
fb share twitter share gplus share more share

This should help you! Just add the lines for minutes and then display it properly with first minutes, then : and then the seconds

Javascript seconds to minutes and seconds - Stack Overflow
BinaryKing is offline  
The Following User Says Thank You to BinaryKing For This Useful Post:
Unread 31st Mar 2014, 02:04 AM   #3
Advanced Warrior
War Room Member
 
zeurois's Avatar
 
Join Date: 2007
Posts: 521
Thanks: 31
Thanked 28 Times in 14 Posts
Default
Re: Ask Countdown Timer
Share on: 
fb share twitter share gplus share more share

This should do the job (I haven't tested it though):

var deadline = 70;

function formatTime(time) {
var minutes = parseInt(time / 60);
var seconds = parseInt(time % 60);
return (minutes < 10 ) ? '0' + minutes : minutes + ':' + (seconds < 10) ? '0' + seconds : seconds;
}

function runTimer() {
deadline--;

$("#mdtimer span").html(formatTime(deadline));

if (sec <= 0) {
$("#makingdifferenttimer").delay(1000).fadeIn(10 00 );
$("#mdtimer").hide(1000) .fadeOut(fast);

return;
}

setTimeout(function(){ runTimer(); }, 1000);
}

zeurois is offline  
Unread 31st Mar 2014, 03:37 AM   #4
HyperActive Warrior
 
tweakr's Avatar
 
Join Date: 2011
Posts: 106
Thanks: 3
Thanked 12 Times in 11 Posts
Default
Re: Ask Countdown Timer
Share on: 
fb share twitter share gplus share more share

Here's what you're looking for:

Code:
jQuery(document).ready(function() {
        var sec = 70;
 
        function formatTime(s) {
            var m = Math.floor(s/60); //Get remaining minutes
            s -= m*60;
            return (m < 10 ? m : m)+":"+(s < 10 ? '0'+s : s); //zero padding on minutes and seconds
        }
 
        var timer = setInterval(function() {
                var count = sec--;
                $("#mdtimer span").text(formatTime(count));
                if (sec == 0) {
                        $("#makingdifferenttimer").delay(1000).fadeIn(1000);
                        $("#mdtimer").hide(1000) .fadeOut(fast);
                }
        }, 1000);
 
});
I created a pastebin with everything in it.

Free AdPress Theme for WordPress .
tweakr is offline  
Unread 31st Mar 2014, 10:36 PM   #5
Active Warrior
 
marioxiao's Avatar
 
Join Date: 2008
Location: Stoneville
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts
Default
Re: Ask Countdown Timer
Share on: 
fb share twitter share gplus share more share

It's working. thanks a million. you're great

marioxiao is offline  
Closed Thread


Bookmarks

Tags
countdown, timer

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 04:54 PM.