Hawaii is one of the simplest places to work with time zones,
no daylight savings adjustments are needed.
This example keeps the Hawiian time string updated
by checking the local time every 5 seconds,
and changing the display when the minutes change.
Code:
<!doctype html>
<html lang="en">
<head>
<meta charset= "utf-8">
<title>Hawaiian time</title>
<script>
var hitimer;
function getHiTime(){
var days= ['Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday'],
h, m, mod, now= new Date();
now.setUTCHours(now.getUTCHours()-10);
h= now.getUTCHours();
mod= h<12? " am":" pm";
if(h>12) h -= 12;
else if(h== 0) h= 12;
m=now.getUTCMinutes()+'';
while(m.length<2)m+='0';
return days[now.getUTCDay()]+ ' '+ h+ ':'+ m+ mod;
}
function showHiTime(){
var who= document.getElementById('HiTime'),
say= who.firstChild.data,
when= getHiTime();
if(say!= when) who.firstChild.data= when;
}
window.onload=function(){
showHiTime();
hiTimer= setInterval(showHiTime, 5000);
}
</script>
</head>
<body>
<h3>Hawaiian standard time: <span id="HiTime">(GMT-10 hours)</span></h3>
</body>
</html>
Bookmarks