Every line of 'javascript convert utc to specific timezone' 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.
42 function utcToLocal(utc) 43 { 44 return new window.BrowserAutomationStudio_OriginalDate(utc.getTime() - TimezoneOffset*60*1000); 45 }
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
30 function getTimeZone(tz) { 31 return (tz == null) ? -new Date().getTimezoneOffset() : tz; 32 }
20 private convertTimezone(tz: string): number { 21 if (tz == "Z") return 0; 22 23 var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/); 24 25 if (m) { 26 return (m[1] == '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60; 27 } 28 29 return 0; 30 }
17 function setTimeZone() { 18 const indianTimeZone = moment 19 .utc() 20 .add(5, "hours") 21 .add(30, "minutes"); 22 return indianTimeZone; 23 }
5 export function fromUTC (utcHour) { 6 return moment.utc(utcHour, 'H').local() 7 }
4 function treatAsUtc(dateStr) { 5 let result = new Date(dateStr); 6 result.setMinutes(result.getMinutes() - result.getTimezoneOffset()); 7 return result; 8 }
50 offset(ts) { 51 return -new Date(ts).getTimezoneOffset(); 52 }
49 function 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 }
21 export function dateToUTC(timestamp) { 22 const date = new Date(timestamp * 1000); 23 return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 24 date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()); 25 }
10 export function inferTimezone(current: string | undefined): string { 11 if (current) { 12 return current; 13 } 14 const browserTime = maybeResolveTZ(); 15 if (browserTime) { 16 if (ONLY_ONCE.need_to_talk) { 17 alert(t(Content.TIMEZONE_GUESS_BROWSER)); 18 ONLY_ONCE.need_to_talk = false; 19 } 20 // WARNING SIDE EFFECTS!!! 21 return browserTime; 22 } 23 if (ONLY_ONCE.need_to_talk) { 24 alert(t(Content.TIMEZONE_GUESS_UTC)); 25 ONLY_ONCE.need_to_talk = false; 26 } 27 return "UTC"; 28 }