Totally agree with Emma and Alveera! In fact, when I’m building user dashboards, I often need both timezone and offset together. So here’s a little pro tip: why not combine both techniques into a single neat function? If you’re serious about your javascript get timezone needs, this is a very practical approach.
function getClientTimeZoneAndOffset() {
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const offsetMinutes = new Date().getTimezoneOffset();
const sign = offsetMinutes > 0 ? '-' : '+';
const hours = Math.floor(Math.abs(offsetMinutes) / 60);
const minutes = Math.abs(offsetMinutes) % 60;
const utcOffset = `UTC${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
return { timeZone, utcOffset };
}
const { timeZone, utcOffset } = getClientTimeZoneAndOffset();
console.log('Time Zone:', timeZone);
console.log('UTC Offset:', utcOffset);
This way you get a full timezone snapshot in one call — both the descriptive timezone and the numeric UTC offset. Especially useful if you’re storing client info for later use. It’s an easy yet powerful addition to any javascript get timezone solution you’re building.