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:
efrick
2020-04-09 13:56:48 -04:00
parent a53376f57e
commit c63c654ead
2 changed files with 80 additions and 29 deletions

View File

@@ -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;
}