javascript - How can I output long datetime format which includes timzone with moment-timezone and react-intl? -


i have client code using react-intl display currency, language, , date time values in user's defined language , region (culture/locale). in addition these requirements want show timezone abbreviation when using long date , time format (ex. 8 february 2016, 15:02 gmt).

to i've attempted use moment-timezone module seems right thing in isolation. i've found in application react-intl used same line of code produces correct data in wrong date-time format.

document.write(moment(date()).tz("europe/london").format('lll z')); 

expected: 8 february 2016 20:57 gmt

actual: february 8, 2016 9:04 pm gmt

my guess has fact i'm not loading in moment en-us local directly since moment being loaded in automatically me part of react-intl library using following type of code.

addlocaledata(en);  var intldata = {     "locales": ["en-us", "en-gb"],     "formats": {         "date": {             "short": {                 "day": "numeric",                 "month": "long",                 "year": "numeric"             },             "longdatetime": {                 "day": "numeric",                 "month": "long",                 "year": "numeric",                 "hour": "numeric",                  "minute": "numeric"             }         },         "time": {             "hhmm": {                 "hour": "numeric",                 "minute": "numeric"             }         }     } };   const provider = <intlprovider locale="en-gb" {...intldata}><myapp /></intlprovider>; 

related:

as temporary workaround found can set locale moment-timezone so.

import moment 'moment-timezone'  moment.locale('en-gb'); 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -