Search code examples
javascripttimestamp-with-timezone

how to convert unix timestamp to date+time for a given timzone


In JavaScript, I have unix timestamp, how do i convert it to data+time for any given timezone, regardless of the local timezone? I am especially interested in US/eastern


Solution

  • You can use the property .toLocaleString and set the desired timeZone

    const unixTimestamp = 1548979200000; 
    new Date(unixTimestamp).toLocaleString("en-US", {timeZone: "US/Eastern"})