Change formating of clock.js

This commit is contained in:
20xd6 2020-04-11 13:19:45 -04:00
parent c7a0849ef5
commit d0d3682ce1

View File

@ -3,7 +3,7 @@
*/ */
window.onload = startInterval; window.onload = startInterval;
function startInterval(){ function startInterval(){
setInterval("startTime();",1000); setInterval("startTime();",1000);
} }
/* The function to update and format the time displayed on the page. /* The function to update and format the time displayed on the page.
* The formating of Date() objects useing .toLocalString() is documented * The formating of Date() objects useing .toLocalString() is documented
@ -12,28 +12,28 @@ function startInterval(){
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
*/ */
function startTime(){ function startTime(){
var current_time = new Date(), var current_time = new Date(),
our_tz = current_time.getTimezoneOffset; our_tz = current_time.getTimezoneOffset;
document.getElementById('time_title').innerHTML = "Time is: " document.getElementById('time_title').innerHTML = "Time is: "
+ current_time.toLocaleString('en-US', + current_time.toLocaleString('en-US',
{timeZone: current_tz, {timeZone: current_tz,
hourCycle:'h24', hourCycle:'h24',
timeStyle:'long', timeStyle:'long',
hour: '2-digit', hour: '2-digit',
minute:'2-digit', minute:'2-digit',
second:'2-digit', second:'2-digit',
timeZoneName:'short'}); timeZoneName:'short'});
document.getElementById('time_body').innerHTML = current_time.toLocaleString('en-EN' ,{ document.getElementById('time_body').innerHTML = current_time.toLocaleString('en-EN' ,{
timeZone: current_tz, timeZone: current_tz,
dateStyle:'long', dateStyle:'long',
hourCycle:'h24', hourCycle:'h24',
weekday:'short', weekday:'short',
month:'short', month:'short',
day:'2-digit', day:'2-digit',
year:'numeric', year:'numeric',
hour:'2-digit', hour:'2-digit',
minute:'2-digit', minute:'2-digit',
second:'2-digit', second:'2-digit',
timeZoneName:'short'}); timeZoneName:'short'});
document.getElementById('JStz').innerHTML = current_tz; document.getElementById('JStz').innerHTML = current_tz;
} }