Setup a proper dropdown for timezone selection.
Some cleanup of the code was done. Some of the testing and debug code needs removal.
This commit is contained in:
37
clock.js
37
clock.js
@@ -5,7 +5,12 @@ window.onload = startInterval;
|
||||
function startInterval(){
|
||||
setInterval("startTime();",1000);
|
||||
}
|
||||
|
||||
/* The function to update and format the time displayed on the page.
|
||||
* The formating of Date() objects useing .toLocalString() is documented
|
||||
* at the following urls:
|
||||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/DateTimeFormat
|
||||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
|
||||
*/
|
||||
function startTime(){
|
||||
var current_time = new Date(),
|
||||
our_tz = current_time.getTimezoneOffset,
|
||||
@@ -13,15 +18,27 @@ function startTime(){
|
||||
+ 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;
|
||||
+ current_time.toLocaleString('en-US',
|
||||
{timeZone: current_tz,
|
||||
hourCycle:'h24',
|
||||
timeStyle:'long',
|
||||
hour: '2-digit',
|
||||
minute:'2-digit',
|
||||
second:'2-digit',
|
||||
timeZoneName:'short'});
|
||||
//document.getElementById('time_title').innerHTML = current_tz;
|
||||
document.getElementById('time_body').innerHTML = current_time.toLocaleString(
|
||||
{timeZone: current_tz},
|
||||
{dateStyle:"long"},
|
||||
{hour12: "false"});
|
||||
document.getElementById('time_body').innerHTML = current_time.toLocaleString('en-EN' ,{
|
||||
timeZone: current_tz,
|
||||
dateStyle:'long',
|
||||
hourCycle:'h24',
|
||||
weekday:'short',
|
||||
month:'short',
|
||||
day:'2-digit',
|
||||
year:'numeric',
|
||||
hour:'2-digit',
|
||||
minute:'2-digit',
|
||||
second:'2-digit',
|
||||
timeZoneName:'short'})
|
||||
+ " " + current_time.getTimezoneOffset();
|
||||
document.getElementById('JStz').innerHTML = current_tz;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user