Previously it was only posiable to use the browers default timezone. To be done: Add more timezones to the list of possiable ones. Clean up the formating of the updating clock to match the php generated inishal date string.
28 lines
990 B
JavaScript
28 lines
990 B
JavaScript
/*Clock functionality. When the page is loaded it starts a one second
|
|
* long loop to update the time displayed on the page.
|
|
*/
|
|
window.onload = startInterval;
|
|
function startInterval(){
|
|
setInterval("startTime();",1000);
|
|
}
|
|
|
|
function startTime(){
|
|
var current_time = new Date(),
|
|
our_tz = current_time.getTimezoneOffset,
|
|
formated_time = current_time.getHours() + ":"
|
|
+ current_time.getMinutes() + ":"
|
|
+ current_time.getSeconds();
|
|
document.getElementById('time_title').innerHTML = "Time is: "
|
|
+ formated_time.toLocaleString(
|
|
{timeZone: current_tz},
|
|
{dateStyle: "full"},
|
|
{hour12: "false"})
|
|
+ " " + current_tz;
|
|
//document.getElementById('time_title').innerHTML = current_tz;
|
|
document.getElementById('time_body').innerHTML = current_time.toLocaleString(
|
|
{timeZone: current_tz},
|
|
{dateStyle:"long"},
|
|
{hour12: "false"});
|
|
document.getElementById('JStz').innerHTML = current_tz;
|
|
}
|