React Intl Formatting date
Asked Answered
R

1

9

i have incoming date in exactly like this string:

myDate= ' 2017-05-05T12:24:06+0000'

i am using FormattedDate from 'react-intl' to achieve my desired format

12:24, 5 May 2017

But with this code:

<FormattedDate
  value={myDate}
  day="numeric"
  month="long"
  year="numeric"
  hour="numeric"
  minute="numeric"/>

i am getting this :

May 5, 2017, 12:24 

i must be doing something wrong. Or misunderstood docs. Can you advise me ?

I

Rosenstein answered 7/5, 2017 at 14:1 Comment(4)
Can you add a link to the mentioned docs?Otherdirected
github.com/yahoo/react-intl/wiki/API#date-formatting-apisRosenstein
It seems all correct to me, also judging from this: github.com/yahoo/react-intl/wiki/Components#formatteddate , you cannot change the standard default format, or pass a custom format along?Otherdirected
You can change the style of every component but you cannot change their order. The order is defined by i18n.Bloemfontein
C
9

Try to combine with FormattedTime of the same library

<FormattedTime value={myDate}/>,&nbsp;<FormattedDate
  value={myDate}
  day="numeric"
  month="long"
  year="numeric"/>
Chong answered 7/5, 2017 at 14:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.