Countdown Clock with Pause and Resume
How do I make an countdown clock with pause and resume?
This is a 10-minute JavaScript countdown clock with pause and resume buttons.. What is a countdown clock with pause and resume? How do you make a countdown clock with pause and resume? This script and codes were developed by Yaphi on 18 July 2022, Monday.
Countdown Clock with Pause and Resume - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Countdown Clock with Pause and Resume</title>
</head>
<body> Countdown Clock with Pause and Resume Functionality
<br><br>
<div id="clockdiv"></div>
<button id="pause">Pause</button>
<button id="resume">Resume</button>
<br><br>
<a href="http://simplestepscode.com/" target="_blank">Simple Steps Code</a> <script src="js/index.js"></script>
</body>
</html>
Countdown Clock with Pause and Resume - Script Codes JS Codes
// 10 minutes from now
var time_in_minutes = 10;
var current_time = Date.parse(new Date());
var deadline = new Date(current_time + time_in_minutes*60*1000);
function time_remaining(endtime){ var t = Date.parse(endtime) - Date.parse(new Date()); var seconds = Math.floor( (t/1000) % 60 ); var minutes = Math.floor( (t/1000/60) % 60 ); var hours = Math.floor( (t/(1000*60*60)) % 24 ); var days = Math.floor( t/(1000*60*60*24) ); return {'total':t, 'days':days, 'hours':hours, 'minutes':minutes, 'seconds':seconds};
}
var timeinterval;
function run_clock(id,endtime){ var clock = document.getElementById(id); function update_clock(){ var t = time_remaining(endtime); clock.innerHTML = 'minutes: '+t.minutes+'<br>seconds: '+t.seconds; if(t.total<=0){ clearInterval(timeinterval); } } update_clock(); // run function once at first to avoid delay timeinterval = setInterval(update_clock,1000);
}
run_clock('clockdiv',deadline);
var paused = false; // is the clock paused?
var time_left; // time left on the clock when paused
function pause_clock(){ if(!paused){ paused = true; clearInterval(timeinterval); // stop the clock time_left = time_remaining(deadline).total; // preserve remaining time }
}
function resume_clock(){ if(paused){ paused = false; // update the deadline to preserve the amount of time remaining deadline = new Date(Date.parse(new Date()) + time_left); // start the clock run_clock('clockdiv',deadline); }
}
// handle pause and resume button clicks
document.getElementById('pause').onclick = pause_clock;
document.getElementById('resume').onclick = resume_clock;
Developer | Yaphi |
Username | yaphi1 |
Uploaded | July 18, 2022 |
Rating | 3 |
Size | 2,095 Kb |
Views | 78,936 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
JavaScript Slideshow With Controls | 2,676 Kb |
Quickipedia - Instant Wikipedia Summaries | 2,318 Kb |
Glow Pong | 2,844 Kb |
Scheduled JavaScript Countdown Clock | 2,068 Kb |
Updated JavaScript Countdown Clock | 2,411 Kb |
JavaScript Slideshow With Pause Button | 2,190 Kb |
RequestAnimationFrame Countdown fork | 1,732 Kb |
Basic JavaScript Countdown Clock | 1,806 Kb |
10 Minute Countdown Clock | 1,845 Kb |
Perspective Test | 1,694 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
LAMP PURE CSS with Animation | Dam62500 | 2,911 Kb |
RollOver Effect 2 | Lmack90 | 2,162 Kb |
My Interests | Anshusaxenaarora | 2,015 Kb |
Haml Calendar | Katydecorah | 5,643 Kb |
Simple blog concept | Drew_mc | 2,666 Kb |
Free css icon set v2 - one div | Ben_jammin | 0 Kb |
A Pen by Malith Hettiarachchi | MalZiiirA | 5,531 Kb |
See Through | Larrygeams | 77,410 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!