Timestamp

A React component for displaying a datetime in the local timezone
Usage
npm install react-timestamp
Then:
const Timestamp = require('react-timestamp');
Use UTC times for the time
prop.
<Timestamp time={thing.created_at} />
<Timestamp time={thing.created_at} precision={2} />
<Timestamp time="2015-10-10 10:30:00" format='full' />
<Timestamp time="2015-10-10 10:30:00" utc={false} format='full' />
<Timestamp time="1450663457" />
<Timestamp time="1450663457" format='full' includeDay />
<Timestamp time="1450663457" since="145060000" />
<Timestamp time="1450663457" until="145070000" />
<Timestamp time="1450663457" until="145070000" autoUpdate />
<Timestamp time="1450663457" until="145070000" autoUpdate={60} />
Format options are:
- 'ago' (default) - 2 hours ago
- 'full' - 10 Oct 2015, 4:32pm
- 'date' - 10 Oct 2015
- 'time' - 4:32pm
Precision works like this:
<Timestamp time={SOME DATE} precision={3} />
<Timestamp time={SOME DATE} precision={2} />
<Timestamp time={SOME DATE} precision={1} />
Usage with React Native
If you are using React Native then you'll have to pass in Text
.
import Timestamp from 'react-timestamp';
import { Text } from 'react-native';
Then:
<Timestamp time="1450663457" component={Text} />
Testing
npm test