Post by Mithras on Jul 25, 2006 8:33:23 GMT -8
This is my first code I've submitted, and I don't know your exact criteria, but here it goes:
<script type="text/javascript">
// Clock With Same Time for All Timezones By Mithras
// www.support.proboards.com
// Do not repost -- this header must remain in tact.
var timeZone;
var Message = new Array(9);
var clockLabel;
var timeString;
var message
// ** Edit **
timeZone = -4;
clockLabel = "Illiath Time--";
Message[0] = " :: Early Morning";
Message[1] = " :: Dawn";
Message[2] = " :: Morning";
Message[3] = " :: Noon";
Message[4] = " :: Afternoon";
Message[5] = " :: Evening";
Message[6] = " :: Dusk";
Message[7] = " :: Night";
Message[8] = " :: Midnight";
// ** Do Not Edit **
var time = new Date();
var timezoneoffset = time.getTimezoneOffset();
var minutes;
var hours;
time.setTime(time.getTime() + timezoneoffset*60*1000);
time.setTime(time.getTime() + timeZone*60*60*1000);
timeString = clockLabel + ' ';
if(time.getHours() > 12) {
timeString += time.getHours() - 12;
} else {
timeString += time.getHours();
}
timeString += ':';
if(time.getMinutes() < 10)
timeString += '0' + time.getMinutes();
else
timeString += time.getMinutes();
if(time.getHours()<6) {
currentMessage = Message[0];
} else if (time.getHours() == 6 && time.getMinutes() == 0) {
currentMessage = Message[1];
} else if (time.getHours() >= 6 && time.getHours() < 12) {
currentMessage = Message[2];
} else if (time.getHours() == 12 && time.getMinutes() == 0) {
currentMessage = Message[3];
} else if (time.getHours() >= 12 && time.getHours() < 17) {
currentMessage = Message[4];
} else if (time.getHours() >= 17 && time.getHours() < 21) {
currentMessage = Message[5];
} else if (time.getHours() == 21 && time.getMinutes() == 0) {
currentMessage = Message[6];
} else if (time.getHours() >= 21 && time.getHours() < 24) {
currentMessage = Message[7];
} else if (time.getHours() == 24 && time.getMinutes() == 0) {
currentMessage = Message[8];
} else {
currentMessage = " ";
}
timeString += currentMessage
document.write('<div align="center" class="clock">' + timeString + '<br><\/div>')
</script>
Edit the green for your time zone, edit the red for the messages you want displayed.
This code will display the same time, no matter what time zone the user is in. I originally made this for an RPG forum.
Here are some screen shots of it:
This one shows where the editted variables will be.
Eastern Time
Central Time
GMT
<script type="text/javascript">
// Clock With Same Time for All Timezones By Mithras
// www.support.proboards.com
// Do not repost -- this header must remain in tact.
var timeZone;
var Message = new Array(9);
var clockLabel;
var timeString;
var message
// ** Edit **
timeZone = -4;
clockLabel = "Illiath Time--";
Message[0] = " :: Early Morning";
Message[1] = " :: Dawn";
Message[2] = " :: Morning";
Message[3] = " :: Noon";
Message[4] = " :: Afternoon";
Message[5] = " :: Evening";
Message[6] = " :: Dusk";
Message[7] = " :: Night";
Message[8] = " :: Midnight";
// ** Do Not Edit **
var time = new Date();
var timezoneoffset = time.getTimezoneOffset();
var minutes;
var hours;
time.setTime(time.getTime() + timezoneoffset*60*1000);
time.setTime(time.getTime() + timeZone*60*60*1000);
timeString = clockLabel + ' ';
if(time.getHours() > 12) {
timeString += time.getHours() - 12;
} else {
timeString += time.getHours();
}
timeString += ':';
if(time.getMinutes() < 10)
timeString += '0' + time.getMinutes();
else
timeString += time.getMinutes();
if(time.getHours()<6) {
currentMessage = Message[0];
} else if (time.getHours() == 6 && time.getMinutes() == 0) {
currentMessage = Message[1];
} else if (time.getHours() >= 6 && time.getHours() < 12) {
currentMessage = Message[2];
} else if (time.getHours() == 12 && time.getMinutes() == 0) {
currentMessage = Message[3];
} else if (time.getHours() >= 12 && time.getHours() < 17) {
currentMessage = Message[4];
} else if (time.getHours() >= 17 && time.getHours() < 21) {
currentMessage = Message[5];
} else if (time.getHours() == 21 && time.getMinutes() == 0) {
currentMessage = Message[6];
} else if (time.getHours() >= 21 && time.getHours() < 24) {
currentMessage = Message[7];
} else if (time.getHours() == 24 && time.getMinutes() == 0) {
currentMessage = Message[8];
} else {
currentMessage = " ";
}
timeString += currentMessage
document.write('<div align="center" class="clock">' + timeString + '<br><\/div>')
</script>
Edit the green for your time zone, edit the red for the messages you want displayed.
This code will display the same time, no matter what time zone the user is in. I originally made this for an RPG forum.
Here are some screen shots of it:
This one shows where the editted variables will be.
Eastern Time
Central Time
GMT