Skip to content Skip to sidebar Skip to footer

Converting Unix Timestamp To Pst

Hi I have a json which I am getting some data. There the time format I am getting is like 1367023443000 I want to convert this to the Normal PST format. Ive tried using Javascript`

Solution 1:

If you're not actually in the US Pacific Time zone, the only way to do this reliably in JavaScript is with a library that implements the TZDB database. I list several of them here.

For example, using walltime-js library, you can do the following:

var date = newDate(1367023443000);
var pacific = WallTime.UTCToWallTime(date, "America/Los_Angeles");
var s = pacific.toDateString() + ' ' + pacific.toFormattedTime();

// output:  "Fri Apr 26 2013 5:44 PM"

You can't just add or subtract a fixed number, because the target time zone may use a different offset depending on exactly what date you're talking about. This is primarily due to Daylight Saving Time, but also because time zones have changed over time.

Post a Comment for "Converting Unix Timestamp To Pst"