jsheroes / community-help

Helping others is fun, ask away and the ClujJavaScripters community will help you!
15 stars 0 forks source link

need advice about date internationalization with JavaScript #2

Closed paulbrie closed 8 years ago

paulbrie commented 8 years ago

Hi all,

this topic seems trivial, but I've spent quite some time on it. So here it is.

I'm using React for a website localized in two languages: RO, EN. My dates are coming from the server in ISO format (example: 2016-09-18T21:15:28.594Z).

Now I would like to localize this date in a human readable format for RO and EN. I would like to get:

I don't find any native solution for this problem. The closest would be toLocaleDateString('fr-FR') - which by the way accepts a localisation parameter, but is still not enough. At this point there's only http://momentjs.com/docs/#/i18n/ which has some solid localization but I wondered if you guys know other ways.

crissmoldovan commented 8 years ago

did u look into this?

https://github.com/jquery/globalize

i was a bit mislead by the fact it's part of jquery. nothing to do with it

raulmatei commented 8 years ago

hi Paul,

As you mentioned, Moment.js seems to be the most useful for dates, because is flexible enough. For React I used react-intl you can find it here https://github.com/yahoo/react-intl

alexpausan commented 8 years ago

as @raulmatei said, for React you could use react-intl, I've used it and it's quite simple and it has support for date

paulbrie commented 8 years ago

Thanks to all! That was really helpful, I have a good overview about the options. Will let you know about my choice. Thanks! ;)