Pen Settings

HTML

CSS

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

JavaScript

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

Behavior

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.

HTML

              
                <h1>How many times has your heart beat since you were born?</h1>
<h2>Please select your birthday.</h2>
<br>
<input id="pick" type="date" name="pname">
<button type="button" id="clicky">Submit</button>
<p id="time7"></p>
<iframe id="frame" src="https://giphy.com/embed/oupKcowRzsad2" width="480" height="360" frameBorder="0" class="giphy-embed" allowFullScreen></iframe>
<br>
<p id="disc">*This is based on adult human averages. Numbers are considered an approximation. Your health, age, or other factors may make your actual count vary from the number shown.</p>
              
            
!

CSS

              
                * {
  text-align: center;
  font-family: arial, sans-serif;
  background-color: #fff;
  color: #1474ba;
}

h1 {
  font-size: 2.5em;
	margin-top: 50px;
  font-weight: bold;
}

h2 {
  margin-bottom: 10px;
  color: darkgray;
}

p {
  font-size: 1.3em;
}

input {
  background-color: lightgray;
  color: black;
  font-size: 1.3em;
}

button {
  color: white;
  background-color: lime;
  border-radius: 10px;
  margin-left: 10px;
  font-size: 1.2em;
  width: 6%
}

#time7 {
  font-size: 2em;
  color: lime;
  padding-top: 40px;
  font-weight: bold;
  width: 750px;
  margin: auto;
}

#disc {
	font-size: .7em;
	width: 500px;
	text-align: center;
	color: darkgray;
	margin: auto;
	margin-top: 1px;
}

#frame {
  visibility: hidden;
}
              
            
!

JS

              
                document.getElementById("clicky").onclick = findDays;
function findDays() {
  var dayt = new Date();
  var today = dayt.getTime();
  var bday =  new Date(document.getElementById("pick").value);
  var cday = bday.getTime();
  var totalTime = today - cday;
  final(Math.floor(totalTime / (1000 * 60 * 60 * 24)) * 100800); 
}
	
function final(days) { 
	var date = new Date();
	var selectedDate = new Date(document.getElementById("pick").value + "T00:00:00");
  var count = document.getElementById("time7")
  var seen = document.getElementById("frame")
	
  if (document.getElementById("pick").value === "") {
    count.innerHTML = "Please enter or select a valid date.";
    count.style.color = "#ff2b00";
    seen.style.visibility = "hidden";
  } 
  if (document.getElementById("pick").value !== "") {
    count.innerHTML = "Your heart has beat approximately " + days + " times since you were born.";
    count.style.color = "lime";
    seen.style.visibility = "visible";
  }
  if (days < 0) {
    count.innerHTML = "You haven't been born yet. Wait, how are you using a computer?";
    count.style.color = "#ff2b00";
    seen.style.visibility = "hidden";
  }	
  if (date.getDate() === selectedDate.getDate() && date.getMonth() === selectedDate.getMonth() && 
	  date.getFullYear() === selectedDate.getFullYear()) {
    count.innerHTML = "You were born today? Lets just say that your heart hasn't beat that much yet.\
      Also, welcome to earth.";
    count.style.color = "darkgray";
    seen.style.visibility = "hidden";
  }	
  if ((date.getDate() - selectedDate.getDate()) === 1 && date.getMonth() === selectedDate.getMonth() && 
	  date.getFullYear() === selectedDate.getFullYear()) {
    count.innerHTML = "You were born yesterday? There's definitely room\
      for a joke here, but you heart hasn't done that much work yet.";
    count.style.color = "darkgray";
    seen.style.visibility = "hidden";
  }
  if ((date.getDate() - selectedDate.getDate()) === -1 && date.getMonth() === selectedDate.getMonth() && 
	  date.getFullYear() === selectedDate.getFullYear() ) {
    count.innerHTML = "Choose a date in the past.";
    count.style.color = "#ff2b00";
    seen.style.visibility = "hidden";
  }
if (date.getDate() === selectedDate.getDate() && date.getMonth() === selectedDate.getMonth() && 
	  date.getFullYear() !== selectedDate.getFullYear()) {
    count.innerHTML = "Your heart has beat approximately " + days +
      " times since you were born. Also, HAPPY BIRTHDAY!"
    count.style.color = "lime";
    seen.style.visibility = "visible";
  }	
  
}
              
            
!
999px

Console