js get timezone code example
Example 1: js get iana timezone
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)
Example 2: javascript set date to timezone
var d = new Date("2020-04-13T00:00:00.000+08:00");
d.toLocaleString('en-US', { timeZone: 'America/New_York' });
Example 3: client timezone offset in JavaScript
var clientTimezoneOffset = new Date().getTimezoneOffset()/60;
Example 4: get browser timezone javascript
Intl.DateTimeFormat().resolvedOptions().timeZone
Example 5: javascript date timezone
const start = Date.now();
console.log('starting timer...');
setTimeout(() => {
const millis = Date.now() - start;
console.log(`seconds elapsed = ${Math.floor(millis/1000)}`);
}, 2000);