Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


Save Automatically?

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.


                <div class="container">
  <div class="dates">
    <div class="start">
      <i>Start time:</i> <br />
      <input type="number" min="0" max="24" id="s_h" placeholder="HH" />
      <input type="number" min="0" max="60" id="s_m" placeholder="MM" />
      <input type="number" min="0" max="60" id="s_s" placeholder="SS" />
    <div class="space"></div>
    <div class="end">
      <i>End time:</i> <br />
      <input type="number" min="0" max="24" id="e_h" placeholder="HH" />
      <input type="number" min="0" max="60" id="e_m" placeholder="MM" />
      <input type="number" min="0" max="60" id="e_s" placeholder="SS" />
  <button id="button">Perform some magic ✨</button>
  <div id="output"></div>


                body {
  margin: 0;
  padding: 0;
  font-family: Roboto,"Helvetica Neue",Arial,sans-serif;
  color: #6930C3;
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 100vh;
  background: #4EA8DE;
.dates {
  display: flex;
  text-align: center;
  i {
    margin-bottom: 10px;
  input {
    width: 40px;
    padding: 5px;
    margin-top: 10px;
.space {
  margin: 0px 10px;
button {
  margin-top: 20px;
  font-size: 24px;
  padding: 10px 20px;
  background: #7400B8;
  border-radius: 5px;
  color: #80FFDB;
  cursor: pointer;
    transition: all 0.5s ease;
  &:hover {
    background: #6930C3;
#output {
  margin-top: 20px;
  font-size: 18px;


                const startHour = document.getElementById("s_h"),
  startMinute = document.getElementById("s_m"),
  startSecond = document.getElementById("s_s"),
  endHour = document.getElementById("e_h"),
  endMinute = document.getElementById("e_m"),
  endSecond = document.getElementById("e_s"),
  button = document.getElementById("button"),
  output = document.getElementById("output");

button.addEventListener("click", function () {
  let startDate = new Date(2020,05,05,startHour.value,startMinute.value,startSecond.value);
  let endDate = new Date(2020,05,05,endHour.value,endMinute.value,endSecond.value);
  let difference = endDate.getTime() - startDate.getTime();
  if (difference < 0) {
    output.innerHTML = "Wow dude, you just went back to the future! 👽";
  } else {
    difference = difference / 1000;
    let hourDifference = Math.floor(difference / 3600);
    difference -= hourDifference * 3600;
    let minuteDifference = Math.floor(difference / 60);
    difference -= minuteDifference * 60;
    output.innerHTML = `${hourDifference} hours, ${minuteDifference} minutes, ${difference} seconds`;