This is the HTML and Javascript for my current clock design. I want the ability to change the hours offset on a customization page and for those changes to apply to the display page that the clocks are on. I currently change the offsets from the display page by typing in the TimeZone database name or by typing in the correct timezone offset. So in simple terms I am trying to change the timezone input from another webpage and have it still displayed from my display webpage. Thanks!
HTML Code:
<div class="timZonM" data-time-zone="Asia/Tehran" style="position: absolute; left: 10px; top:545px;"></div>
<div class="timZonM" data-time-zone="Etc/GMT" style="position: absolute; left: 250px; top: 545px;"></div>
<div class="timZonM" data-time-zone="Etc/GMT+4" data-seconds style="position: absolute; left:510px; top:580px;"></div>
<div class="timZonM" data-time-zone="Etc/GMT-8" style="position:absolute; left:920px; top:545px;"></div>
<div class="timZonM" data-time-zone="Etc/GMT-14" style="position:absolute; left:1205px; top:545px;"></div>
Javascript Code:
const OptionsMilitary = { hour12:false, hour:'2-digit', minute:'2-digit', second:'2-digit' };
const MilitaryTime=(elm, dt)=>
{
let [hh,mm,ss] = dt.toLocaleString("en-US", {...OptionsMilitary, timeZone:elm.dataset.timeZone }).split(':')
if ('seconds'in elm.dataset) elm.dataset.seconds = ':'+ss
elm.textContent = (hh=='00'&&mm=='00') ? '2400' : (hh+mm).replace(/^24/, '00'); // specific browsers marmelade
}
setInterval(() => {
let dateTime = new Date();
document.querySelectorAll('.timZonM').forEach(el=>MilitaryTime(el, dateTime));
}, 500);