I have problem showing timezone with moment.js.
I tried with this code:
var result = moment(someDate).format("MM/DD/YYYY HH:mm A Z");
and I get return, for example: 08/05/2015 06:18 PM +02:00
, which is fine, but I want that my output be like 08/05/2015 06:18 PM WEDT
or something like that, with abbreviations of timezones.
Tried using this code, but I get empty timezone on the end:
var result = moment(someDate).format("MM/DD/YYYY HH:mm A z");
or
var result = moment(someDate).format("MM/DD/YYYY HH:mm A zz");
UPDATE
So as @Matt Johnson suggested, I used this approach to show time zone using moment-timezone-with-data.js and tzdetect.js:
var tzName = tzdetect.matches()[0];
var result = moment.tz(myDate, tzName).format("MM/DD/YYYY h:mm A zz");
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…