I want to add a clock to my website that displays Eastern time only. Currently I am not on EST time zone, and the clock is displaying my local time. I was unable to find a reference that does that. Some were discussing connecting to php / ajax sever time..etc which I am unfamiliar with.
Below are the html and js codes I am using.
function showTime(){
var date = new Date();
var h = date.getHours();
var m = date.getMinutes();
h = (h < 10) ? "0" + h : h;
m = (m < 10) ? "0" + m : m;
var time = h + ":" + m;
document.getElementById("MyClockDisplay").innerText = time;
document.getElementById("MyClockDisplay").innerContent = time;
setTimeout(showTime, 1000);
}
showTime();
<body>
<div id="MyClockDisplay"></div>
<script src="./src/clock.js"></script>
</body>