[javascript] Convert date to another timezone in JavaScript

If you don't want to import some big library you could just use Intl.DateTimeFormat to convert Date objects to different timezones.

_x000D_
_x000D_
// Specifying timeZone is what causes the conversion, the rest is just formatting
const options = {
  year: '2-digit', month: '2-digit', day: '2-digit',
  hour: '2-digit', minute: '2-digit', second: '2-digit',
  timeZone: 'Asia/Jakarta',
  timeZoneName: 'short'
}
const formatter = new Intl.DateTimeFormat('sv-SE', options)
const startingDate = new Date("2012/04/10 10:10:30 +0000")

const dateInNewTimezone = formatter.format(startingDate) 
console.log(dateInNewTimezone) // 12-04-10 17:10:30 GMT+7
_x000D_
_x000D_
_x000D_

Offsets, daylight saving, and changes in the past will be taken care of for you.