January Sales Timer

Posted on: Dec 6, 2011 4:15:23 PM By: Viet Le Quang

Happy New Year Everyone! we trust that we all ate and drank thriving amounts of ornithology and sherry respectively all in credentials for a prolonged tough toil that is January. We’re substantially all woeful shopping too most final Christmas as we realize we have a good 4 some-more weeks of no income to demeanour brazen to…joy of joys.

I only wanted to give we a small something for all of we who are environment adult your Jan sales on your magento sites (or even immobile sites). Just a small bit of a JavaScript time that will count down until a finish of a sale (midnight 31st Jan we have set it to).

You can revise this calculator as most as we like – if we know a small javascript we will find this all too easy. Also there are a few styles to use for your convenience.

Simply pulp a next anywhere on your website where we will wish to arrangement a timer.

style type="text/css"
.jansales { font-weight: bold; font-size: 1.2em; }
.jansales camber { font-size: 0.8em; margin: 0 5px 0 2px; }

/style
div
pJanuary Sales End In:/p
div id="januarysales"

/div
/div
script type="text/javascript"

function secondsToTime(secs){
var days = Math.floor(secs / (60 * 60 * 24));
var divisor_for_hours = secs % (60 * 60 * 24);
var hours = Math.floor(divisor_for_hours / (60 * 60));
var divisor_for_minutes = divisor_for_hours % (60 * 60);
var mins = Math.floor(divisor_for_minutes / 60);
var divisor_for_seconds = divisor_for_minutes % 60;
var seconds = Math.ceil(divisor_for_seconds);

if(days.toString().length  2){
days = "0"+days.toString();
}
if(hours.toString().length  2){
hours = "0"+hours.toString();
}
if(minutes.toString().length  2){
minutes = "0"+minutes.toString();
}
if(seconds.toString().length  2){
seconds = "0"+seconds.toString();
}
var obj = {
"d": days,
"h": hours,
"m": minutes,
"s": seconds
};
return obj;
}

function getTheTime(){
var targetdate = "02/01/2011 12:00:00 AM"; // american character date
var currentdate = new Date(); // get stream date
var date = new Date(targetdate);
var currenttime = currentdate.getTime();
var targettime = date.getTime();
var timeleft =  targettime - currenttime;
var timeleft = timeleft / 1000;
var exam = new secondsToTime(timeleft);
if(timeleft  0){
document.getElementById('januarysales').innerHTML = test.d+"spandays/span"+test.h+"spanhours/span"+test.m+"spanminutes/span"+test.s+"spanseconds/span";
} else {
document.getElementById('januarysales').innerHTML = "Our Jan Sales are now strictly over!";
}
}

setInterval('getTheTime()', 1000);

/script