Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- theme switch dark/light -->
<div class="theme">
  <label class="switch"><input id="switch" type="checkbox" />
    <div></div>
  </label>
</div>

<!-- date/time selector -->
<div class="date">
  <input type="datetime-local" id="meeting-time" name="meeting-time">
</div>

<!-- count down text container -->
<div class="container">
  <h1 id="timer_value"></h1>
</div>
              
            
!

CSS

              
                
/* center the text */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

/* timer font size */
h1 {
  max-width: 90%;
  text-align: center;
  font-family: helvetica;
  font-size: 20vw;
}

h1 span{
  display: block;
  font-size: 5vw;
}

.date {
  position: absolute;
  top: 20px;
  right: 20px;
}

/* dark mode switch */
body.dark {
  background-color: black;
  color: white;
}

.theme {
  position: absolute;
  top: 20px;
  left: 20px;
  height: 40px;
  margin: auto;
  text-align: center;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch {
  display: inline-block;
  font-size: 20px;
  height: 1em;
  width: 2em;
  background: #bdb9a6;
  border-radius: 1em;
}

.switch div {
  height: 1em;
  width: 1em;
  border-radius: 1em;
  background: #fff;
  box-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.3);
  -webkit-transition: all 300ms;
  -moz-transition: all 300ms;
  transition: all 300ms;
}

.switch input:checked + div {
  -webkit-transform: translate3d(100%, 0, 0);
  -moz-transform: translate3d(100%, 0, 0);
  transform: translate3d(100%, 0, 0);
}

              
            
!

JS

              
                var timer;
function settimer(dtime) {
  clearInterval(timer);

  var end = new Date(dtime); // Arrange values in Date Time Format
  var now = new Date(); // Get Current date time
  var second = 1000; // Total Millisecond In One Sec
  var minute = second * 60; // Total Sec In One Min
  var hour = minute * 60; // Total Min In One Hour
  var day = hour * 24; // Total Hour In One Day

  function showtimer() {
    var now = new Date();
    var remain = end - now; // Get The Difference Between Current and entered date time
    if (remain < 0) {
      clearInterval(timer);
      document.getElementById("timer_value").innerHTML = "Reached!";
      return;
    }
    if (isNaN(end.getTime())) {
      clearInterval(timer);
      document.getElementById("timer_value").innerHTML = "<span>Select a date at the top right</span>";
      return;
    }
    var days = Math.floor(remain / day); // Get Remaining Days
    var hours = Math.floor((remain % day) / hour); // Get Remaining Hours
    if (days > 0) {
      hours = hours + days * 24;
    }
    var minutes = Math.floor((remain % hour) / minute); // Get Remaining Min
    var seconds = Math.floor((remain % minute) / second); // Get Remaining Sec

    //document.getElementById("timer_value").innerHTML = days + 'd ';
    document.getElementById("timer_value").innerHTML =
      hours.toString().padStart(2, "0") + ":";
    document.getElementById("timer_value").innerHTML +=
      minutes.toString().padStart(2, "0") + ":";
    document.getElementById("timer_value").innerHTML +=
      seconds.toString().padStart(2, "0") + "";
  }
  timer = setInterval(showtimer, 1000); // Display Timer In Every 1 Sec
}

const dateElement = document.getElementById("meeting-time");
dateElement.addEventListener("change", (event) => {
  settimer(event.target.value);
});

const switchElement = document.getElementById("switch");
switchElement.addEventListener("change", (event) => {
  console.log(event.target.checked);
  var body = document.body;

  if (event.target.checked) {
    body.classList.add("dark");
  } else {
    body.classList.remove("dark");
  }
});

settimer();

              
            
!
999px

Console