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

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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

 

以上是关于[React Intl] Format Date and Time Using react-intl FormattedDate and FormattedTime的主要内容,如果未能解决你的问题,请参考以下文章

[React Intl] Format Numbers with Separators and Currency Symbols using react-intl FormattedNumber(代码

Intl.NumberFormat#format 最大整数值

[React Intl] Render Content with Placeholders using react-intl FormattedMessage

[React Intl] Install and Configure the Entry Point of react-intl

为 react/react-intl 动态导入语言 json 文件

非组件的 React-intl