Javascript: Live countdown to date end (With leading zero for number less than 10)
|
<script> CountDownTimer('05/05/2016 05:04 PM'); function CountDownTimer(dt) { var end = new Date(dt); var _second = 1000; var _minute = _second * 60; var _hour = _minute * 60; var _day = _hour * 24; var timer; function showRemaining() { var now = new Date(); var distance = end - now; var days = Math.floor(distance / _day); var hours = Math.floor((distance % _day) / _hour); var minutes = Math.floor((distance % _hour) / _minute); var seconds = Math.floor((distance % _minute) / _second); if (distance < 0) { clearInterval(timer); days = '00'; hours = '00'; minutes = '00'; seconds = '00'; } document.getElementById('countdown_days').innerHTML = addZero(days); document.getElementById('countdown_hrs').innerHTML = addZero(hours); document.getElementById('countdown_mins').innerHTML = addZero(minutes); document.getElementById('countdown_secs').innerHTML = addZero(seconds); } timer = setInterval(showRemaining, 1000); } function addZero(number) { if (number<10) { number = ('0'+number).slice(-2); } return number; } </script>
POSTED BY juong |
Popular Posts
-
Rumi Ke Jawi 1. Convert rumi ke jawi secara online. senang sekali! 2. Lepas covert, copy dan paste kat microsoft word, 3. dan pilih font ...
-
Sebelum download Arabic Dotted / titik-titik, Aracbic font perlu di install terlebih dahulu. Install arabic font di sini Kalau dah install, ...
-
Encoding JSON in PHP Some years ago, JSON support was provided through the json pecl extension. Since PHP 5.2, it is included in the core ...
-
Nowadays, peoples know about programming and think that programming is killer subject. This case, you must set your mind what is better to d...
-
There are many options to change default icon of File Extension. For example we can uses FileTypesMan application, or using manual setting. ...
-
Pattern Result d Numeric day of month without leading zero (1, 7, 31) dd Numeric day of month with leading ...
-
This means that you have too many database connections basically. Unfortunately since the demise of svrctl, it also means that you as a DBA ...
-
Step to remove: Go to Start > Run and type: MSCONFIG , and hit enter. Click on the BOOT.INI tab and then click on "Check All Boot ...
-
Learning content is a digital resource that can be reused to support learning (Wiley, 2002). A learning content can be a single file materia...
-
In Windows 8, now that the Start Menu is now gone and replaced by the Start Screen and Charms bar. This means that if you want to restart yo...
Post a Comment