ajay ramgounda You could use a map to replace the GMT Offset with a zone, but zones respect summer time and GMT Offsets not. So it is a bad solution:
const date = new Date()
const map = new Map([
[-11, 'Pacific/Niue'],
[-10, 'Pacific/Tahiti'],
[-9, 'Pacific/Gambier'],
[-8, 'Pacific/Pitcairn'],
[-7, 'America/Vancouver'],
[-6, 'America/Denver'],
[-5, 'America/Rio_Branco'],
[-4, 'America/Manaus'],
[-3, 'America/Cayenne'],
[-2, 'Atlantic/South_Georgia'],
[-1, 'Atlantic/Azores'],
[0, 'GMT'],
[1, 'Europe/Brussels'],
[2, 'Europe/Helsinki'],
[3, 'Asia/Riyadh'],
[4, 'Asia/Dubai'],
[5, 'Asia/Tashkent'],
[6, 'Asia/Urumqi'],
[7, 'Asia/Bangkok'],
[8, 'Asia/Singapore'],
[9, 'Asia/Chita'],
[10, 'Pacific/Chuuk'],
[11, 'Pacific/Pohnpei'],
[12, 'Pacific/Wake'],
])
date.toLocaleTimeString('en-US', {timeZone: map.get(-6)})
A better solution is a self made converter:
function dateToGMT(date = new Date(), offset = 0) {
let hours = date.getUTCHours() + offset
if (hours > 23) hours = 24 - hours
if (hours < 0) hours = 24 + hours
return `${hours}:${date.getUTCMinutes()}:${date.getUTCSeconds()}`
}
Or you use something like moment.