Coming Soon Page using JavaScript

Coming Soon Page

Introduction

The term "Coming Soon Page" is a landing page or temporary placeholder web page, which displays the notation that a feature, service, product, or website is under development and will be launched soon.


Source Code:

HTML:

<!DOCTYPE html>
<html>
<head>
  <title>Coming Soon Page</title>
  <link rel="stylesheet" href="style.css" />
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" 
  rel="stylesheet" />
</head>
            
<body>
  <div class="container">
    <h1>We're Coming Soon</h1>
    <p>Stay tuned! Something amazing is coming for you.</p>
    <div class="timer" id="timer">
      <div>
        <span id="days">00</span>
        <span>Days</span>
      </div>
      <div>
        <span id="hours">00</span>
        <span>Hours</span>
      </div>
      <div>
        <span id="minutes">00</span>
        <span>Minutes</span>
      </div>
      <div>
        <span id="seconds">00</span>
        <span>Seconds</span>
      </div>
    </div>
  </div>
  <script src="script.js"></script>
</body>
</html>

CSS:

* { 
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
          
body {
  font-family: 'Poppins', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: rgb(62, 62, 255);
  color: #fff;
}
          
.container {
  text-align: center;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
          
h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}
          
p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
}
          
.timer {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: 1.5rem;
  font-weight: 600;
}
          
.timer div {
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
}
          
.timer div span {
  display: block;
  font-size: 1rem;
  font-weight: 400;
  margin-top: 0.5rem;
}

JavaScript:

const targetDate = new Date("2025-02-30T00:00:00");

function updateTimer() {
  const now = new Date();
  const difference = targetDate - now;
      
  if (difference < 0) {
    document.getElementById("timer").innerHTML = "<h2>We're Live!</h2>";
    return;
  }
      
  const days = Math.floor(difference / (1000 * 60 * 60 * 24));
  const hours = Math.floor(
    (difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
  );
  const minutes = Math.floor(
    (difference % (1000 * 60 * 60)) / (1000 * 60)
  );
  const seconds = Math.floor((difference % (1000 * 60)) / 1000);
      
  document.getElementById("days").textContent =
    days < 10 ? "0" + days : days;
  document.getElementById("hours").textContent =
    hours < 10 ? "0" + hours : hours;
  document.getElementById("minutes").textContent =
    minutes < 10 ? "0" + minutes : minutes;
  document.getElementById("seconds").textContent =
    seconds < 10 ? "0" + seconds : seconds;
}
      
updateTimer();
setInterval(updateTimer, 1000);

Output

Output Image