doc=document; Dphp=1231227228*1000; //Гринв.вр.сервера в (php - секундах) (js - мсек) Djs=(D=new Date()).getTime()-D.getTimezoneOffset()*60000; //Гринв.вр.клиента в миллисекундах DD=Dphp-Djs; //onload=function(){setInterval("clock1()",999);clock1();} function clock1() { var D0; D0=new Date hms('timeT',new Date(D0.getTime()+DD+(9*60*60*1000))); } function hms(layr,X) { var m,s; doc.getElementById(layr).innerHTML =X.getHours()+':'+((m=X.getMinutes())<10?'0':'')+m; //+':'+((s=X.getSeconds())<10?'0':'')+s; doc.getElementById('dateT').innerHTML = writeDateLong(7,X); } function longMonthArray() { this[0] = "Января"; this[1] = "Февраля"; this[2] = "Марта"; this[3] = "Апреля"; this[4] = "Мая"; this[5] = "Июня"; this[6] = "Июля"; this[7] = "Августа"; this[8] = "Сентября"; this[9] = "Октября"; this[10] = "Ноября"; this[11] = "Декабря"; return (this); } function shortMonthArray() { this[0] = "Jan"; this[1] = "Feb"; this[2] = "Mar"; this[3] = "Apr"; this[4] = "Май"; this[5] = "Jun"; this[6] = "Jul"; this[7] = "Aug"; this[8] = "Sep"; this[9] = "Oct"; this[10] = "Nov"; this[11] = "Dec"; return (this); } function longDayArray() { this[0] = "Sunday"; this[1] = "Monday"; this[2] = "Tuesday"; this[3] = "Wednesday"; this[4] = "Thursday"; this[5] = "Friday"; this[6] = "Saturday"; return (this); } function shortDayArray() { this[0] = "Sun"; this[1] = "Mon"; this[2] = "Tue"; this[3] = "Wed"; this[4] = "Thu"; this[5] = "Fri"; this[6] = "Sat"; return (this); } function getShortYear(year) { shortyear = year%100; if (shortyear < 10) shortyear = "0"+shortyear; return shortyear } function getLongYear(year) { if (year > 1900) return year return year+1900; } function writeDateLong(format, d) { shortDays = new shortDayArray(); longDays = new longDayArray(); shortMonths = new shortMonthArray(); longMonths = new longMonthArray(); //d = new Date(); //day = d.getDate(); //month = d.getMonth(); //year = d.getYear(); /* var D0; D0=new Date d = new Date(D0.getTime()+DD+(9*60*60*1000)); */ day = d.getDate(); month = d.getMonth(); year = d.getYear(); if (format == 0) str = shortDays[d.getDay()] + " " + shortMonths[month] +". " + day + ", "+getLongYear(year); else if (format == 1) str = shortDays[d.getDay()] + " " + longMonths[month] + " " + day + ", "+getLongYear(year); else if (format == 2) str = longDays[d.getDay()] + " " + longMonths[month] + " " + day + ", "+getLongYear(year); else if (format == 3) str = longMonths[month] + " " + day + ", "+getLongYear(year); else if (format == 4) str = shortDays[d.getDay()] + " " + day + " " + shortMonths[month] +". " +getLongYear(year); else if (format == 5) str = shortDays[d.getDay()] + " " + day + " " + longMonths[month] + " " +getLongYear(year); else if (format == 6) str = longDays[d.getDay()] + " " + day + " " + longMonths[month] + " " + getLongYear(year); else if (format == 7) str = day + " " + longMonths[month]; // + ", "+getShortYear(year); else { month++; shortyear = getShortYear(year); if (format == 8) str = month + "/" + day + "/" + shortyear; else if (format == 9) str = month + "/" + day + "/" + getLongYear(year); else if (format == 10) str = day + "/" + month + "/" + shortyear; else if (format == 11) str = day + "/" + month + "/" + getLongYear(year); else if (format == 12) str = shortyear + "/" + month + "/" + day; else if (format == 13) str = shortyear + "/" + month + "/" + day; else { if (day < 10) day = "0"+day if (month < 10) month = "0"+month if (format == 14) str = month + "/" + day + "/" + shortyear; else if (format == 15) str = month + "/" + day + "/" + getLongYear(year); else if (format == 16) str = day + "/" + month + "/" + shortyear; else if (format == 17) str = day + "/" + month + "/" + getLongYear(year); else if (format == 18) str = shortyear + "/" + month + "/" + day; else if (format == 19) str = shortyear + "/" + month + "/" + day; } } return str; } function writeDate() { writeDateLong(0); } function writeTimeLong(format) { d = new Date(); hour=d.getHours(); min=d.getMinutes(); sec=d.getSeconds(); if (hour < 10) hour = "0"+hour; if (min < 10) min = "0"+min; if (sec < 10) sec = "0"+sec; if (format == 0) str = hour+":"+min+":"+sec; else if (format == 1) str = hour+":"+min; document.writeln(str); } function writeTime() { writeTimeLong(0); }