css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Christmas Countdown</title>
</head>
<body>
<div id="rightcolumn">
    <div id='timer' class='test'></div>
</div>
    
 </body>
 </html>
            
          
!
            
              html{
    background-color: black;
    background: url(http://www.nicholasmaassel.com/images/Christmas_Final.png) no-repeat center center fixed;
    background-size: cover;

    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
}

img.bg{
    width: 100%;
    height: auto;
    overflow: auto;
}

#rightcolumn{
    
}

#timer{
    background-color: rgba( 256, 256, 256, 0.9);
    color: red;
    font-family: futura, verdana, sans-serif;
    font-size: 2.0em;
    margin: 10px 200px 0 20px;
    padding: 1em;
    

   -moz-box-shadow:    inset 0 0 10px #000000;
   -webkit-box-shadow: inset 0 0 10px #000000;
   box-shadow:         inset 0 0 10px #000000;
}
            
          
!
            
              /* Timer Variables */
var Timer;

var dString = "December, 25, 2013";
var targetDate = new Date(dString);

window.onload = function() {
  CreateTimer("timer");
}

function CreateTimer(TimerID) {
    Timer = document.getElementById(TimerID);

    UpdateTimer();
    window.setTimeout("Tick()", 1000);
}

function Tick() {
    UpdateTimer();
    window.setTimeout("Tick()", 1000);
}

function UpdateTimer() {
    var date = new Date();
    
    var Months = getMonthsLeft(date);
    var Days = getDaysLeft(date);
    var Hours = getHoursLeft(date);
    var Minutes = getMinutesLeft(date);
    var Seconds = getSecondsLeft(date);
  
  // Returns one of two expressions depending on a condition
  // test ? expression1 : expression2 
    var TimeStr = Months + Days + LeadingZero(Hours) + ":" + LeadingZero(Minutes) + ":" + LeadingZero(Seconds);

    Timer.innerHTML = TimeStr + " until Christmas!";
}

function LeadingZero(Time) {
    return (Time < 10) ? "0" + Time : +Time;
}

function getMonthsLeft(date) {
  // Get the current month from 0 to 11
  // ex. November is 10 (not 11)
  // Add 1 to make the month # correct
  // ex. November will actually be 11 now
    var currentMonth = date.getMonth() + 1;
    var monthsLeft = 12 - currentMonth;
    return ((monthsLeft > 0) ? monthsLeft + " month" : "");
}
function getDaysLeft(date) {
  var daysLeft = ", ";
  var Month = date.getMonth();
  
  // If we just want the days left in the current month ((Month!=12) or (Month=12 && getDate() > 25))
  if ((Month!=12) || (Month==12 && getDate() > 25)) {
    // http://stackoverflow.com/a/1184359/2895248
    var daysinMonth = new Date(date.getYear(), date.getMonth(), 0).getDate();
    daysLeft += daysinMonth - date.getDate();
    return daysLeft + " days, ";
  }
  
  // If it's December and not yet Christmas
  // subtract the current day from 25
  return daysLeft += date.getDate() - 25 + " days, ";
}
function getHoursLeft(date) {
    var currentHour = date.getHours();
    return 24 - currentHour;
}
function getMinutesLeft(date) {
    var currentMinutes = date.getMinutes();
    return 60 - currentMinutes;
}
function getSecondsLeft(date) {
    var currentSeconds = date.getSeconds();
    return 60 - currentSeconds;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console