You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-timestamp

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-timestamp

A React component for displaying a datetime in the local timezone

4.3.0
Source
npmnpm
Version published
Weekly downloads
1.4K
-8.64%
Maintainers
1
Weekly downloads
 
Created
Source

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' /> <!-- Don't convert the timestamp to local time -->
<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 /> <!-- Updates every second -->
<Timestamp time="1450663457" until="145070000" autoUpdate={60} /> <!-- Updates every minute -->

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} />
<!-- 2 days, 4 hours, 1 minute ago -->

<Timestamp time={SOME DATE} precision={2} />
<!-- 2 days, 4 hours -->

<Timestamp time={SOME DATE} precision={1} />
<!-- 2 days -->

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

Keywords

react

FAQs

Package last updated on 20 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts