[React Intl] Format a Date Relative to the Current Date Using react-intl FormattedRelative
React to The Using Date format Current Relative
2023-09-14 09:00:51 时间
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源码分析看useEffect
- React saga_react获取子组件ref
- Maven报错:The packaging for this project did not assign a file to the build artifact[通俗易懂]
- React v18.x 在 react-router v6 使用 lazy 动态加载组件实现
- 前端常见react面试题合集
- Interview: 2020春季中高级前端面试记 | 渐进增强题目甄选(上篇)-react&http基础
- React Error: Failed at the xxx@0.1.0 start script 'react-scripts start'.
- react源码分析:babel如何解析jsx
- React组件复用的技巧
- React源码分析8-状态更新的优先级机制
- to program_I Just Want To
- 使用React创建一个web3的前端
- react高频面试题总结(附答案)
- 手写迷你版react
- React源码学习进阶(八)setState底层逻辑
- React Fiber 是什么?
- React--5: 类的相关复习
- react 基础之组件篇二——Style in React
- 前端 CST和GMT+0800时间转换(js/vue/react/jsp通用)
- Create React App 创建前端项目
- ORA-27611: Smart I/O failed due to a block corruption detected on the host. The block was received from cell “string”. disk: “string”, block: “string”, disk offset: “string” ORACLE 报错 故障修复 远程处理
- ORA-32341: The EXPLAIN_MVIEW facility failed to explain the materialized view “string”.”string” ORACLE 报错 故障修复 远程处理
- ORA-53410: The attribute string does not conform to the VM rule. ORACLE 报错 故障修复 远程处理
- ECC TO HANA FAGLB03 search-help on Account Number field doesn’t working or not returning the selected value to the Account Number field.详解编程语言
- Exploring the Power of MongoDB: The Definitive Guide to Upgrading Arrays(mongodb更新数组)