Jquery Countdown Timer

by UIDeveloper Works

HTML

<body>
    
     
     <div class="image">

      <img src="http://www.jrbarker.info/wp-content/uploads/2013/02/url.jpeg" height="400" width="400" alt="" />
      
     <h2>Time Left: <span id="timeLeft"></span></h2>

</div>
 </body>

CSS

.image { 
   position: relative; 
   width: 100%; /* for IE 6 */
}

h2 { 
   position: absolute; 
   top: 300px; 
   left: 0; 
   width: 100%; 
}
h2 span { 
   color: white; 
   font: bold 24px/45px Helvetica, Sans-Serif; 
   letter-spacing: -1px;  
   background: rgb(0, 0, 0); /* fallback color */
   background: rgba(0, 0, 0, 0.7);
   padding: 10px; 
}

h2 span.spacer {
   padding:0 5px;
}

JavaScript

function updateTimeSpan() {
    var theSpan = document.getElementById('timeLeft');
    var d = new Date();
    var t = new Date();
    var ms;
    var s, m, h;

    // if it's after 5pm, set today to tomorrow    
    if (d.getHours() > 16){ d.setDate(d.getDate() + 1); }
    // get the next monday    
    while (d.getDay() != 1){ d.setDate(d.getDate() + 1); }
    // set the time    
    d.setHours(23);
    d.setMinutes(18);
    d.setSeconds(0);
    // get the difference between right now and next monday    
    ms = d - t;
    // get the days between now and then    
    d = parseInt(ms / (1000 * 60 * 60 * 24));
    ms -= (d * 1000 * 60 * 60 * 24);
    // get hours    
    h = parseInt(ms / (1000 * 60 * 60));
    ms -= (h * 1000 * 60 * 60);
    // get minutes    
    m = parseInt(ms / (1000 * 60));
    ms -= (m * 1000 * 60);
    // get seconds    
    s = parseInt(ms / 1000);
    theSpan.innerHTML = d + ' days, ' + h + ' hours, ' + m + ' minutes, and ' + s + ' seconds.';
    setTimeout('updateTimeSpan()', 100);
}

onload = updateTimeSpan();

$(function() {
    
    $("h2")
        .wrapInner("<span>")

    $("h2 br")
        .before("<span class='spacer'>")
        .after("<span class='spacer'>");

});