cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <h1>Count Down to <span class='endDate'></span></h1>
 
<h2 class='timer'></h2>
 
<dl>
  <dt>Total Seconds Left</dt>
  <dd class='seconds'></dd>
  <dt>Total Minutes Left</dt>
  <dd class='minutes'></dd>
  <dt>Total Hours Left</dt>
  <dd class='hours'></dd>
  <dt>Total Days Left</dt>
  <dd class='days'></dd>
</dl>
            
          
!
            
              dl {
  dt { font-weight: bold; }
  dd { margin: 0.3em 0 1em 0; }
}
.timer {
  background-color: #333;
  color: #fff;
  padding: 1em;
  text-align: center;
  border-radius: 0.4em;
  box-shadow: #999 0.2em 0.2em 0.5em;
  text-shadow: #222 0.1em 0.1em 0.2em;
}
            
          
!
            
              $(document).ready(function(){
  console.log("Document Ready");
  var _departureDate = new Date();
  var _now = new Date();
  _departureDate.setMonth(_now.getMonth()+1);

  $('.endDate').html(_departureDate.toDateString());
  
  setInterval(function() {
    var _today = new Date();
 
    var _countdown = _departureDate - _today;
    var _remainingTime = _departureDate - _today;
    var _timer_days = parseInt(_remainingTime/86400000);
    _remainingTime = _remainingTime - (_timer_days*86400000);
    var _timer_hours = parseInt(_remainingTime / 3600000);
    _remainingTime = _remainingTime - (_timer_hours*3600000);
    var _timer_mins = parseInt(_remainingTime / 60000);
    _remainingTime = _remainingTime - (_timer_mins*60000);
    var _timer_sec = parseInt(_remainingTime / 1000);
    
    var _output_timer_string = "";
    if (_timer_days > 0) {
      _output_timer_string += _timer_days + " day";
      if (_timer_days > 1) { _output_timer_string += "s"; }
      _output_timer_string += " ";
    }
    if (_timer_hours > 0) {
      _output_timer_string += _timer_hours + " hour";
      if (_timer_hours > 1) { _output_timer_string += "s"; }
      _output_timer_string += " ";
    }
    if (_timer_mins > 0) {
      _output_timer_string += _timer_mins + " minute";
      if (_timer_mins > 1) { _output_timer_string += "s"; }
      _output_timer_string += " and ";
    }
    _output_timer_string += _timer_sec + " seconds";
    $('.timer').html(_output_timer_string);
    
    var _sec = parseInt(_countdown / 1000);
    var _mins = parseInt(_sec / 60);
    var _hours = parseInt(_mins / 60);
    var _days = parseInt(_hours / 24);
    
    $('.seconds').html(_sec);
    $('.minutes').html(_mins);
    $('.hours').html(_hours);
    $('.days').html(_days);
  }, 500);
});
            
          
!
999px
Loading ..................

Console