Home > General > Affiliate Marketing Forum

Countdown Timer with Miniute Second & Millisecond (5)


01-22-2015 04:26 PM #1 avn_0903 (Member)
Countdown Timer with Miniute Second & Millisecond

Hi there, I'm looking for a countdown timer script that can display decreasing minutes, seconds and milliseconds in this format 00:00:00. I have done my research on STM forum and so far there is only a timer that displays seconds and milliseconds only. Also, I know that beggars can't be choosers but I would really appreciate it if I can customize this timer (font size, color and font type).

If anybody has a countdown timer with the above attributes then please contact me thank you so much!


01-22-2015 07:04 PM #2 caurmen (Administrator)

Milliseconds are tricky: http://stackoverflow.com/questions/2...h-milliseconds

My favourite countdown timer is this one: http://keith-wood.name/countdown.html . No Milliseconds but otherwise very good.


01-23-2015 02:47 AM #3 stipes (Member)

You can try with this, I've created this half sleepy but I hope it will work.
Here is the Javascript:

Code:
var seconds = 120;
var hundreds = 0;
function secondPassed() {
	var minutes = Math.round((seconds - 30)/60);
	var remainingSeconds = seconds % 60;
	if (remainingSeconds < 10) {
		remainingSeconds = "0" + remainingSeconds; 
	}
	
	document.getElementById('countdown').innerHTML = minutes + ":" + remainingSeconds + ":" + hundreds;
	
	if (hundreds === 0){
		if (seconds === 0) {
			clearInterval(countdownTimer);
			document.getElementById('countdown').innerHTML = "Buzz Buzz";
		} 
		else {
			seconds--;
            hundreds = 100;
		}
	}
	else{
		hundreds--;
	}
}
var countdownTimer = setInterval('secondPassed()', 10);
Here is the HTML part:
HTML Code:
<span id="countdown" class="timer"></span>
You can preview the output here: http://jsbin.com/dufewaperu/1/
And you can easily style it using class or id of html element.


01-23-2015 05:42 AM #4 avn_0903 (Member)

Thanks guy, exactly what I needed


02-02-2015 05:36 AM #5 peterpan (Member)

Here is what I use:

Code:
<script type="text/javascript">
        
        // Set how many seconds to count down, milli stays at 1000
        var seconds = 30;
        var milli = 1000;
        var timeoutval;

        function Timer() {
            
            timeoutval = setTimeout(Timer, 10);

            if (seconds < 0) {
                // Stop the timeout function
                clearTimeout(timeoutval);
                // Do Something like close window or redirect page.
                window.location.href = "http://nldvr.voluumtrk.com/click";
            }
            else {
                // if the milli seconds is below zero, de-increment(is that even a word??) the second and reset milliseconds
                if (milli < 0) {
                    seconds--;
                    milli = 1000;
                }
                else {
                   // Display the countdown
                    DisplayCountdown();
                }
                
                // de-increment milli by 10, 10 seemed to work the best
                milli = milli - 10;
            }
        }

        function DisplayCountdown() {
            
            // Fill a span tag with the id of timer
            var timer = document.getElementById('timer');
            
            // The code below pads the millisecond string so the value doesn't jump around
            if (milli < 10) {
                timer.innerHTML = seconds + '.00' + milli;
            }
            else if (milli < 100) {
                timer.innerHTML = seconds + '.0' + milli;
            }
            else {
                timer.innerHTML = seconds + '.' + milli;
            }

        }

        Timer();
	
	</script>
It auto-redirects after it goes to 0


Home > General > Affiliate Marketing Forum