Nhập mã<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<title>Đồng Hồ Đếm Ngược</title>
<style>
body {
font-family: Arial, sans-serif;
background: #1e1e1e;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
h1 {
margin-bottom: 20px;
}
#countdown {
font-size: 2rem;
background: #333;
padding: 20px;
border-radius: 10px;
}
</style>
</head>
<body>
<h1>Đếm Ngược Đến Năm Mới!</h1>
<div id="countdown">Đang tải...</div>
<script>
const countdownElement = document.getElementById("countdown");
const targetDate = new Date("Jan 1, 2026 00:00:00").getTime();
function updateCountdown() {
const now = new Date().getTime();
const distance = targetDate - now;
if (distance < 0) {
countdownElement.innerHTML = "Chúc mừng năm mới!";
return;
}
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
countdownElement.innerHTML = `${days} ngày ${hours} giờ ${minutes} phút ${seconds} giây`;
}
setInterval(updateCountdown, 1000);
updateCountdown(); // gọi lần đầu để không bị delay 1s
</script>
</body>
</html>
của bạn ở đây...