[React Intl] Format Date and Time Using react-intl FormattedDate and FormattedTime

Using the react-intl FormattedDate and FormattedTime components, we’ll render a JavaScript Date into both a date string and a time string in different language formats.,

 

FormattedDate and FormattedTime, they are similar, just FormattedTime contains both time and date.

<div>
                {
                  /**
                  
                    <FormattedDate value={new Date(review.date)}
                      year='2-digit'
                      month='2-digit'
                      day='2-digit' />
                   */
                }
                <FormattedTime 
                  year='2-digit'
                  month='2-digit'
                  day='2-digit'
                  value={new Date(review.date)} />
</div>

 

Display as such:

04/20/17, 9:16 AM

 

posted @ 2017-07-28 20:01  Zhentiw  阅读(729)  评论(0编辑  收藏  举报