How to use 'add timezone offset to date javascript' in JavaScript

Every line of 'add timezone offset to date javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
49function timeZoneGetter(date) {
50 var zone = -1 * date.getTimezoneOffset();
51 var paddedZone = (zone >= 0) ? "+" : "";
52
53 paddedZone += padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) +
54 padNumber(Math.abs(zone % 60), 2);
55
56 return paddedZone;
57}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

6function timezoneAbbr(date){
7 // Date.toString gives different results depending on the
8 // browser/system so we fallback to timezone offset
9 // chrome: 'Mon Apr 08 2013 09:02:04 GMT-0300 (BRT)'
10 // IE: 'Mon Apr 8 09:02:04 UTC-0300 2013'
11 var tz = /\(([A-Z]{3,4})\)/.exec(date.toString());
12 return tz? tz[1] : timezoneOffset(date);
13}

Related snippets