Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
*PAYING for help*
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="TrueJewix" data-source="post: 364668" data-attributes="member: 20416"><p>For some reason my counter won't move, I've tried everything.</p><p></p><p></p><p><div id="countdown"></div></p><p></p><p> <script></p><p>// set the date we're counting down to</p><p>var target_date = new Date("Feb 19, 2016").getTime();</p><p></p><p>// variables for time units</p><p>var days, hours, minutes, seconds;</p><p></p><p>// get tag element</p><p>var countdown = document.getElementById("countdown");</p><p></p><p>// update the tag with id "countdown" every 1 second</p><p>setInterval(function () {</p><p></p><p> // find the amount of "seconds" between now and target</p><p> var current_date = new Date().getTime();</p><p> var seconds_left = (target_date - current_date) / 1000;</p><p></p><p> // do some time calculations</p><p> days = parseInt(seconds_left / 86400);</p><p> seconds_left = seconds_left % 86400;</p><p> </p><p> hours = parseInt(seconds_left / 3600);</p><p> seconds_left = seconds_left % 3600;</p><p> </p><p> minutes = parseInt(seconds_left / 60);</p><p> seconds = parseInt(seconds_left % 60);</p><p> </p><p> // format countdown string + set tag value</p><p> countdown.innerHTML = days + " days " + hours + " hours "</p><p> + minutes + " minutes and " + seconds +" seconds"; </p><p></p><p>}, 1000);</p><p> </script></p><p></p><p>div#countdown {</p><p> margin-left: 109px;</p><p>}</p></blockquote><p></p>
[QUOTE="TrueJewix, post: 364668, member: 20416"] For some reason my counter won't move, I've tried everything. <div id="countdown"></div> <script> // set the date we're counting down to var target_date = new Date("Feb 19, 2016").getTime(); // variables for time units var days, hours, minutes, seconds; // get tag element var countdown = document.getElementById("countdown"); // update the tag with id "countdown" every 1 second setInterval(function () { // find the amount of "seconds" between now and target var current_date = new Date().getTime(); var seconds_left = (target_date - current_date) / 1000; // do some time calculations days = parseInt(seconds_left / 86400); seconds_left = seconds_left % 86400; hours = parseInt(seconds_left / 3600); seconds_left = seconds_left % 3600; minutes = parseInt(seconds_left / 60); seconds = parseInt(seconds_left % 60); // format countdown string + set tag value countdown.innerHTML = days + " days " + hours + " hours " + minutes + " minutes and " + seconds +" seconds"; }, 1000); </script> div#countdown { margin-left: 109px; } [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
*PAYING for help*
Top