Jquery Daily Timer
I'm trying to find a jQuery timer that will countdown to 10am everyday, monday to friday. On friday it will countdown to 10am monday.
I've tried KK Countdown but it seems a little difficult to modify.
The timezone will be set to one specific zone, as its a local website onl开发者_开发知识库y.
Any Ideas anyone? I can only use javascript no PHP unfortunately as the website is a hosted e-commerce solution.
Depending on the complexity of your requirements it can sometimes be exciting to reinvent the wheel. I think you can accomplish yours in just a few lines ... but then again there might be stuff I am not thinking of.
// 24 hour based
var targetHour = 10;
var currentTime = new Date();
// sun 0 mon 1 ... fri 5 sat 6
var currentDay = currentTime.getDay();
var offset = 24;
// friday
if (currentDay === 5) {
offset = 60;
} // saturday
else if(currentDay === 6) {
offset = 48;
}
if(currentTime.getHours() > targetHour) {
console.log('hours:', (targetHour + offset) - currentTime.getHours() - 1);
console.log('minutes:', 60 - currentTime.getMinutes());
}
else if(currentTime.getHours() < targetHour) {
console.log(targetHour - currentTime.getHours() - 1);
console.log('minutes:', 60 - currentTime.getMinutes());
}
There's a list of jQuery countdown timers here -
http://www.tripwiremagazine.com/2011/04/9-cool-jquery-countdown-scripts.html
精彩评论