I've found that toLocaleString can be effective in translating the time to a different timezone, as discussed on this question already. For example, to print the time in New York:
console.log(new Date().toLocaleString("en-US", {timeZone: "America/New_York"}))
"5/26/2020, 1:27:13 PM"
That's great; this code gives me what time it is in New York, but only in string format. If I want to do something programmatic based on the hours, I'll have to parse that string.
Is there a way I can generate a date object with a specific timezone, without coercing it into a string? For example, I want this imaginary function:
const newYork = new Date().toTimezone('America/New_York')
console.log(newYork.getHours(), newYork.getMinutes())
13 27 // <--- 13:27 (1:27pm) in New York, not the browser's timezone
Is that possible in JavaScript?