nathanhoad / react-timestamp

A React component for displaying a UTC datetime in the local timezone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Timestamp

Render a nice looking time.

Usage

If you only provide a date then it will just format it nicely:

<Timestamp date={Date} /> // 26 Mar 2018, 10:30am

If you enable relative then you'll get something like:

<Timestamp relative date={Date} /> // 4 hours ago
<Timestamp relative date={Date} /> // in 4 hours
<Timestamp relative date={Date} relativeTo={Date} /> // 4 hours
<Timestamp relative date={Date} relativeTo={Date} /> // 2 years

<Timestamp relative date={Date} autoUpdate /> // 1 minute ago, 2 minutes ago, 3 minutes ago

Other options are set by passing an options prop:

<Timestamp date={Date} options={{ includeDay: true, twentyFourHour: true }} /> // Tuesday, 26 Mar 2018, 16:30

Authors

About

A React component for displaying a UTC datetime in the local timezone

License:MIT License


Languages

Language:TypeScript 92.3%Language:JavaScript 6.2%Language:HTML 1.4%