mirror of
https://github.com/strapi/strapi.git
synced 2025-07-31 04:45:54 +00:00
Update packages/core/helper-plugin/src/components/RelativeTime/index.js
Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com>
This commit is contained in:
parent
4ad16d5dcd
commit
e1b51c84c5
@ -8,12 +8,15 @@ import { useIntl } from 'react-intl';
|
|||||||
* Displays the relative time between a given timestamp and the current time.
|
* Displays the relative time between a given timestamp and the current time.
|
||||||
* You can display a custom message for given time intervals by passing an array of custom intervals.
|
* You can display a custom message for given time intervals by passing an array of custom intervals.
|
||||||
*
|
*
|
||||||
* @example <caption>Display "last hour" if the timestamp is less than an hour ago</caption>
|
* @example
|
||||||
|
* ```jsx
|
||||||
|
* <caption>Display "last hour" if the timestamp is less than an hour ago</caption>
|
||||||
* <RelativeTime
|
* <RelativeTime
|
||||||
* timestamp={new Date('2021-01-01')}
|
* timestamp={new Date('2021-01-01')}
|
||||||
* customIntervals={[
|
* customIntervals={[
|
||||||
* { unit: 'hours', threshold: 1, text: 'last hour' },
|
* { unit: 'hours', threshold: 1, text: 'last hour' },
|
||||||
* ]}
|
* ]}
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
const RelativeTime = ({ timestamp, customIntervals }) => {
|
const RelativeTime = ({ timestamp, customIntervals }) => {
|
||||||
const { formatRelativeTime, formatDate, formatTime } = useIntl();
|
const { formatRelativeTime, formatDate, formatTime } = useIntl();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user