A component to display time formatted in "calendar time," or "time ago." For instance, given a time 10 minutes previous to now, the component will render "10 minutes ago." Additionally, the component updates this calendar time with an interval.
The component works seamlessly with both react-native and the web (via react-native-web)
yarn add @dschau/react-native-timeago
import React from 'react-native';
import {
View
} from 'react-native';
import TimeAgo from '@dschau/react-native-timeago';
export default function TimeAgoContainer() {
return (
<View>
<TimeAgo time={new Date('01/01/1970')} />
</View>
);
}
Use to set the "start" date for comparison to now. Accepts number
, string
, or Date
.
Sets the prefix to display before to the calendar time. For instance, prefix="as of"
will render as of X ago
.
Default is false
.
Sets the suffix to display after the calendar time. For instance, suffix="some time ago"
will render 10 minutes some time ago
.
Default is ago
, set to false
to disable.
Set the interval to customize when now
is re-set.
Default is 60000
(1 minute in MS)
Set to add a className
to the internal Text
element
Default is ''
Customize the internal style of the internal Text
element