Reputation: 2225
I am trying to display a time in the current named timezone using moment timezone.
The time is stored in the database in UTC as 2014-07-22 11:11:06. Whatever I try I cannot display the time as 12:11 even though the named timezone is Europe/London.
var timestamp = 1406023866000; // converted from database stored as UTC 2014-07-22 11:11:06
var zone = tz.name(); // Europe/London
var utc = moment(timestamp); // create a moment from the timestamp
var time = utc.tz(zone); // _d: Date {Tue Jul 22 2014 12:11:06 GMT+0100 (GMT Standard Time)}
// _f: undefined
// _i: 1406023866000
formatted = time.format('h:mma'); // 11:11am - should be 12.11pm because of BST
Upvotes: 0
Views: 347
Reputation: 3757
Assuming that your timestamp is in milliseconds, 1406023866000 = GMT: Tue, 22 Jul 2014 10:11:06 GMT.
I used http://www.epochconverter.com/
Upvotes: 1