Added the ability to change the timezone of the clock.
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.
This commit is contained in:
19
clock.js
19
clock.js
@@ -1,4 +1,6 @@
|
||||
|
||||
/*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);
|
||||
@@ -6,9 +8,20 @@ function startInterval(){
|
||||
|
||||
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;
|
||||
document.getElementById('time_body').innerHTML = Date();
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user