I have one date time
Date_Dubai=2017-12-29 01:00 AM Asia/Dubai
and i have to convert it to "Asia/Kolkota" in "Date_Dubai" format.
I have one date time
Date_Dubai=2017-12-29 01:00 AM Asia/Dubai
and i have to convert it to "Asia/Kolkota" in "Date_Dubai" format.
dt = new Date();
localTime = dt.getTime(); //current localtime in milisecond.
localOffset = dt.getTimezoneOffset() * 60000;
//getTimezoneOffset() returns in minutes so converting it into millisecond(*60000).
The time-zone offset is the difference, in minutes, between UTC and local time. Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead.(Doc)
Get the current UTC time, by adding the local time zone offset to the local time.
utc = localTime + localOffset;
After getting UTC time, get the destination city's UTC offset in hours. Here Dubai offset is +4 hours.
offset = 4; // GST (Gulf Standard Time) ahead +4 hours from utc
dubaiTime = utc + (3600000*offset); // convert offset into milisecond and add to UTC time.
newTime = new Date(dubaiTime);
console.log(newTime);
More info about Date Object