Накидал скрипт таймера, вдруг пригодится
var TheInternational = new Date("31 Aug 2012 12:00:00 GMT-0700"); //Время назначения с преферансом и куртизанками, а так же часовыми поясами
var msecLeft = 0;
function Timer_Tick() {
if(msecLeft <= 0) return;
var Time = DateTime(msecLeft); //Time array Day:Hour:Min:Sec
Update(Time);
msecLeft -= 1000;
}
function Update (Time) {
var dayElem = document.getElementById("day");
dayElem.firstChild.nodeValue = FormatX2(Time[0]);
var hourElem = document.getElementById("hour");
hourElem.firstChild.nodeValue = FormatX2(Time[1]);
var minElem = document.getElementById("minute");
minElem.firstChild.nodeValue = FormatX2(Time[2]);
var secElem = document.getElementById("second");
secElem.firstChild.nodeValue = FormatX2(Time[3]);
}
function FormatX2(value) {
var retVal = ("00" + value).slice(-2);
return retVal;
}
function DateTime(millisec) {
var days = Math.floor(millisec / (60 * 60 * 1000 * 24) * 1);
var hours = Math.floor((millisec % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1);
var minutes = Math.floor(((millisec % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1)
var seconds = Math.floor((((millisec % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1);
return [days, hours, minutes, seconds];
}
//собственно реквестим время отсюда
//http://json-time.appspot.com/time.json?callback=TimeCallback
function TimeCallback(json) {
var now = new Date(json.datetime);
msecLeft = TheInternational - now;
}
setInterval("Timer_Tick()", 1000);