jay3ld
05-12-2005, 02:22 PM
im looking for a time script to display the time no matter the zone
Heres my current script
I can change the time. but other people in other time zones see it differnt still
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////Customization///////////////////////////////////
//Set the separator between the time hours, mins, and seconds
//Set the Time bgcolor to change its color background
//Set the 12 hour to 1 to only go to 12 and display am and pm
var myTime_spacer = ":"
var myTime_bgcolor = "white"
var myTime_Image = ""
var myTime_12 = 1;
//Put more by a / Example: Verdana, Arial, Helvetica, sans-serif
//Not all computers got the same fonts. so putting more would make your clock look better
//Set the Size it you want A size of Text. +1 and -5 numbers work also
var myFont_Face = "Verdana"
var myFont_Size = "+4"
var myFont_color = "White"
////////////////////////////END Customization///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////TIME SCRIPT///////////////////////////////////
/////////////////////DO NOT EDIT THIS! YOU MIGHT BREAK IT///////////////////////
var isNav=(navigator.appName.indexOf("Netscape")!=-1);
var localTime = new Date();
var myTime = new Date();
var hoursOffset = Math.floor(localTime.getTimezoneOffset() / 60);
/* Pacific is +17 Mountain is +18 Central is +19 East is +20 */
myTime.setHours(localTime.getHours() + hoursOffset - 0);
myTime.setMinutes(localTime.getMinutes());
var timeHour = myTime.getHours();
var timeMinute = myTime.getMinutes();
var timeSecond = myTime.getSeconds();
function startClock() {
setInterval("updateClock()",0);
}
function doubleDigits(digits) {
if (digits < 10) digits = "0" + digits;
return(digits);
}
var page_loaded; // set true onload (avoid errors onmouseover/out before page loaded)
function writeToLayer(id, sHTML) {
// if (!page_loaded) return;
var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
if (!el) return;
var cntnt = '<div class="myTime">' + sHTML + '</div>';
if (typeof el.innerHTML!="undefined") {
el.innerHTML = cntnt;
} else if (document.layers) {
el.document.write(cntnt);
el.document.close();
}
}
function updateClock() {
timeSecond++;
if (timeSecond >= 60) {
timeSecond = timeSecond - 60;
timeMinute++;
}
if (timeMinute >= 60) {
timeMinute = timeMinute - 60;
timeHour++;
}
// if (timeHour >= 12) {
// timeHour = timeHour - 12;
// timeHour++;
if (myTime_12) {
dn = " AM";
if (timeHour > 11) { dn = " PM"; timeHour = timeHour - 12; }
if (timeHour == 0) { timeHour = 12; }
} else {
dn = " Militray Time";
}
timeString = doubleDigits(timeHour) +myTime_spacer + doubleDigits(timeMinute) +dn;
formattedTime = '<font size='+myFont_Size+'><div style="background-color: '+myTime_bgcolor+'; background-image: url('+myTime_Image+'); layer-background-image: url('+myTime_Image+');">' + timeString + '</div>';
writeToLayer('TimeLayer',formattedTime);
}
Heres my current script
I can change the time. but other people in other time zones see it differnt still
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////Customization///////////////////////////////////
//Set the separator between the time hours, mins, and seconds
//Set the Time bgcolor to change its color background
//Set the 12 hour to 1 to only go to 12 and display am and pm
var myTime_spacer = ":"
var myTime_bgcolor = "white"
var myTime_Image = ""
var myTime_12 = 1;
//Put more by a / Example: Verdana, Arial, Helvetica, sans-serif
//Not all computers got the same fonts. so putting more would make your clock look better
//Set the Size it you want A size of Text. +1 and -5 numbers work also
var myFont_Face = "Verdana"
var myFont_Size = "+4"
var myFont_color = "White"
////////////////////////////END Customization///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////TIME SCRIPT///////////////////////////////////
/////////////////////DO NOT EDIT THIS! YOU MIGHT BREAK IT///////////////////////
var isNav=(navigator.appName.indexOf("Netscape")!=-1);
var localTime = new Date();
var myTime = new Date();
var hoursOffset = Math.floor(localTime.getTimezoneOffset() / 60);
/* Pacific is +17 Mountain is +18 Central is +19 East is +20 */
myTime.setHours(localTime.getHours() + hoursOffset - 0);
myTime.setMinutes(localTime.getMinutes());
var timeHour = myTime.getHours();
var timeMinute = myTime.getMinutes();
var timeSecond = myTime.getSeconds();
function startClock() {
setInterval("updateClock()",0);
}
function doubleDigits(digits) {
if (digits < 10) digits = "0" + digits;
return(digits);
}
var page_loaded; // set true onload (avoid errors onmouseover/out before page loaded)
function writeToLayer(id, sHTML) {
// if (!page_loaded) return;
var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
if (!el) return;
var cntnt = '<div class="myTime">' + sHTML + '</div>';
if (typeof el.innerHTML!="undefined") {
el.innerHTML = cntnt;
} else if (document.layers) {
el.document.write(cntnt);
el.document.close();
}
}
function updateClock() {
timeSecond++;
if (timeSecond >= 60) {
timeSecond = timeSecond - 60;
timeMinute++;
}
if (timeMinute >= 60) {
timeMinute = timeMinute - 60;
timeHour++;
}
// if (timeHour >= 12) {
// timeHour = timeHour - 12;
// timeHour++;
if (myTime_12) {
dn = " AM";
if (timeHour > 11) { dn = " PM"; timeHour = timeHour - 12; }
if (timeHour == 0) { timeHour = 12; }
} else {
dn = " Militray Time";
}
timeString = doubleDigits(timeHour) +myTime_spacer + doubleDigits(timeMinute) +dn;
formattedTime = '<font size='+myFont_Size+'><div style="background-color: '+myTime_bgcolor+'; background-image: url('+myTime_Image+'); layer-background-image: url('+myTime_Image+');">' + timeString + '</div>';
writeToLayer('TimeLayer',formattedTime);
}