I have a client in Hawaii who offering a few books for sale on his website. He wants to post his local time on the contact page, along with his phone number and office hours. The idea is that people will see it is too early or late to call.
I am not Javascript savy, so I am seeking help on the code below. I think my coding effort below is showing the user’s browser time, not Hawaii time (which is -10:00 UTC).
<script language="JavaScript">
var d=new Date();
var n=d.toLocaleTimeString();;
document.write(n);
</script>
After crawling the JS Date Object and Methods I am at a loss at this point. Any one got a minute?
A better option is to use PHP. The first question to ask, though, is where the server for the website is located. If it’s in Hawaii, that’s easier, as you just display the current server time on screen. If the server is located elsewhere, you just need to tweak the time setting first.
I researched the PHP timezone code for Hawaii: Pacific/Honolulu; but the contact page is already HTML. HostMonster is the server owner, phpinfo.php reports Default timezone America/Denver. And Wikipedia reports MST -7 UTC and (daylight saving) MDT -6 UTC.
My thoughts are: get UTC time and subtract 10 hours. JS Date Methods: getUTCHours() and getUTCMinutes() and getUTCSeconds() seem to be the only way to get the UTC time.