Given a date, we’ll use the react-intl FormattedRelative component to render a date in a human readable format, such as “2 days ago”, in various languages.

We'll also see how to set the frequency of this component's rendering to make our app update the text in real-time.

                <FormattedRelative
value={new Date(review.date)}
style="numeric"
/>

Since the FormattedRelative component udpate in real time, so you can also control the update interval:

                <FormattedRelative
value={new Date(review.date)}
updateInterval={1000}
style="numeric"
/>

Notice that it will cause extra unecessary component render.

[React Intl] Format a Date Relative to the Current Date Using react-intl FormattedRelative的更多相关文章

  1. [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 ...

  2. java中setDate(Date date)方法和String与Date之间的转换

    经常在开发的过程中遇到这样的问题,从数据库中读出来的数据需要转换为对像或者java bean,此时经常使用到setDate(Date date);这样的方法.感觉这是个很简单而又难受的事情,在这里浪费 ...

  3. 【转】Date类学习总结(Calendar Date 字符串 相互转换 格式化)

    原文网址:http://www.blogjava.net/jerry-zhaoj/archive/2008/10/08/233228.html Date类学习总结 1.计算某一月份的最大天数 Cale ...

  4. javascript 的Date 格式化, 模仿shell中date命令的格式

    原文:javascript 的Date 格式化, 模仿shell中date命令的格式 shell 中显示当前的日期 [root@localhost]$ date '+%Y-%m-%d %H:%M:%S ...

  5. jackson/fastjson、mybatis、mysql date/datatime/timestamp、java Date/Timestamp关系详解

    jackson/fastjson序列化/反序列化: 默认情况下,jackson/fastjson将java Date/Timestamp类型序列化为时间戳,也就是1970年1月1日0点以来的毫秒数.如 ...

  6. Java – How to add days to current date

    1. Calendar.add Example to add 1 year, 1 month, 1 day, 1 hour, 1 minute and 1 second to the current ...

  7. Java – How to get current date time

    Java – How to get current date time 1. Code SnippetsFor java.util.Date, just create a new Date() Dat ...

  8. Date类学习总结(Calendar Date 字符串 相互转换 格式化)

    Date类学习总结 1.计算某一月份的最大天数 Calendar time=Calendar.getInstance();time.clear();time.set(Calendar.YEAR,yea ...

  9. 对Date的扩展,将 Date 转化为指定格式的String

    <script language="javascript" type="text/javascript"><!-- /** * 对Date的扩 ...

随机推荐

  1. python调用Java代码,完毕JBPM工作流application

    1.缘由 有一庞大Python django webproject,要引入工作流引擎,像OA一样.方便的流程控制与管理.Python或django关于工作流的开源插件,稀少,并且弱爆了,终于选用jav ...

  2. openssl之BIO系列之25---结束语

    (作者:DragonKing, Mail: wzhah@263.net ,公布于:http://openssl.126.com之ope nssl专业论坛) 经过半个月左右,最终将BIO的结构和各个分支 ...

  3. 平板电脑上完美体验Windows 8 (视频)

    平板电脑上完美体验Windows 8 (视频) 目前,计算机产业正面临重大变革,三网融合,云计算,物联网正加速终端产品的融合.4C融合成为终端产品的未来发展趋势,是4C融合的代表性产品,它破了传统的W ...

  4. Oracle中NVL、NVL2、DECODE函数的用法

    DECODE函数的用法:   DECODE(value,if1,then1,if2,then2,if3,then3,......,else),表示如果value的值等于if1时,DECODE函数的结果 ...

  5. php中this,self,parent三个关键字的区别辨析

    php中this,self,parent三个关键字的区别辨析 一.总结 一句话总结:this是指向对象实例的一个指针,self是对类本身的一个引用,parent是对父类的引用. 1.self关键字使用 ...

  6. IE中实现placeholder

    简介:IE本身不支持Placeholder这种先进的特性,但是我们又必须且仅仅支持IE,所以网上找了一个支持placeholder的方法 考虑版权,以及知识产权原因,只放链接: http://blog ...

  7. 仙人掌的同构(hash)

    关于仙人掌的同构,主要是我太蒟蒻了QAQ,问了好几位大佬才弄好. 手撕仙人掌,你得先有手套 ,你得先了解以下基本知识 a.点双连通分量,没什么好说得,仙人掌上有环,判环用点双 b.树的hash点这里 ...

  8. 初学WCF需要注意的地方

    1.WCF的元数据发布有两种方式: a.HTTP-GET方式发布数据:让客户端使用HTTP-GET方式来获取数据是比较常见的方式.所谓HTTP—GET方式,是指当客户端发送一个HTTP-GET请求时, ...

  9. Java Web学习总结(1)——JavaWeb开发入门

    一.基本概念 1.1.WEB开发的相关知识 WEB,在英语中web即表示网页的意思,它用于表示Internet主机上供外界访问的资源. Internet上供外界访问的Web资源分为: 静态web资源( ...

  10. Elasticsearch入门系列~通过Java一系列操作Elasticsearch

    Elasticsearch索引的创建.数据的增删该查操作 上一章节已经在Linux系统上安装Elasticsearch并且可以外网访问,这节主要通过Java代码操作Elasticsearch 1.创建 ...