Event Countdown Timer (HTML/CSS/JavaScript)
Description:
A simple web app that lets users set a future event date and shows a real-time countdown in
days, hours, minutes, and seconds.
[Link]
html
CopyEdit
<!DOCTYPE html>
<html>
<head>
<title>Countdown Timer</title>
<style>
body { font-family: sans-serif; text-align: center; margin-top: 50px; }
input, button { padding: 10px; font-size: 16px; margin: 10px; }
h2 { margin-top: 30px; }
</style>
</head>
<body>
<h1>Event Countdown</h1>
<input type="datetime-local" id="eventTime">
<button onclick="startCountdown()">Start</button>
<h2 id="countdown"></h2>
<script>
function startCountdown() {
const eventTime = new Date([Link]("eventTime").value).getTime();
const countdownElement = [Link]("countdown");
setInterval(() => {
const now = new Date().getTime();
const diff = eventTime - now;
if (diff < 0) {
[Link] = "Event Started!";
return;
const days = [Link](diff / (1000 * 60 * 60 * 24));
const hours = [Link]((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = [Link]((diff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = [Link]((diff % (1000 * 60)) / 1000);
[Link] = `${days}d ${hours}h ${minutes}m ${seconds}s`;
}, 1000);
</script>
</body>
</html>