The Intl.DateTimeFormat object in JavaScript provides the language-specific date and time formatting methods.

To get the system’s IANA time zone, you use the following code snippet:

const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
console.log(timezone) // Asia/Karachi

If you need a local time zone offset from the UTC time and not the actual time zone (Asia/Karachi), you should use the getTimezoneOffset() method instead:

const date = new Date()
const offset = date.getTimezoneOffset()
console.log(offset)    // -300 (Because Asia/Karachi is +05:00 UTC)

The getTimezoneOffset() returns the time difference, in minutes, between UTC time and local time.

The returned value is positive if the local time zone is behind UTC and negative if the local time zone is ahead of UTC.