Quantcast
Channel: Getting the client's time zone (and offset) in JavaScript - Stack Overflow
Viewing all articles
Browse latest Browse all 34

Answer by Abhish Abraham for Getting the client's time zone (and offset) in JavaScript

$
0
0

This would be my solution:

    // For time zone:    const timeZone = /\((.*)\)/.exec(new Date().toString())[1];    // Offset hours:    const offsetHours = new Date().getTimezoneOffset() / 60;    console.log(`${timeZone}, ${offsetHours}hrs`);

Viewing all articles
Browse latest Browse all 34

Trending Articles