JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://momentjs.com/downloads/moment.js"></script>
<script src="http://momentjs.com/downloads/moment-timezone-with-data-2010-2020.js"></script>
JavaScript
function awayFromHomeTZ(tz) {
var there = moment.tz(tz);
var here = moment();
var thereHHMM = there.hour() * 60 + there.minute();
var hereHHMM = here.hour() * 60 + here.minute();
return Math.abs(thereHHMM - hereHHMM) > 59;
}
var tests = ["America/Halifax", "America/New_York", "America/Chicago", "America/Denver", "America/Vancouver", "America/Anchorage"];
var yourIn = null;
for(var i = 0; i < tests.length; i++) {
if(!awayFromHomeTZ(tests[i])) {
if(yourIn == null) {
yourIn = tests[i];
} else {
alert("Test failed: " + yourIn + " " + tests[i]);
}
}
}
if(yourIn == null) {
alert("You are not in an American time zone");
} else {
alert("You are in " + yourIn);
}