JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' id='state' value='TX' />
<input type='button' value='Update Time' id='update' />
<br /><br />
<input type='text' id='currenttime' />
JavaScript
function GetClientTime() {
// current time
var dt = new Date();
// pacific time
var pacifictime = dt.getHours() - 2 + ":" + (dt.getMinutes() < 10 ? '0' : '') + dt.getMinutes();
// mountain time
var mountaintime = dt.getHours() - 1 + ":" + (dt.getMinutes() < 10 ? '0' : '') + dt.getMinutes();
// central time
var centraltime = dt.getHours() + ":" + (dt.getMinutes() < 10 ? '0' : '') + dt.getMinutes();
// eastern time
var easterntime = dt.getHours() + 1 + ":" + (dt.getMinutes() < 10 ? '0' : '') + dt.getMinutes();
// get am/pm
var hours = new Date().getHours();
var ampm = (hours >= 12) ? "PM" : "AM";
var pacificstates = [
"WA", "OR", "CA", "NV"
]
if ($('#state').val() == pacificstates) {
$('#currenttime').show().val(pacifictime + " " + ampm);
} else if ($('#state').val() == 'CO') {
$('#currenttime').show().val(mountaintime + " " + ampm);
} else if ($('#state').val() == 'TX' || $('#state').val() == 'LA') {
$('#currenttime').show().val(centraltime + " " + ampm);
} else if ($('#state').val() == 'NY' || $('#state').val() == 'NJ') {
$('#currenttime').show().val(easterntime + " " + ampm);
} else {
$('#currenttime').hide();
}
}
GetClientTime();
$('#update').click(function(){
GetClientTime();
})