Skip to content

Commit

Permalink
Merge dbb0fe6 into 8da6d12
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmazanik committed Jan 17, 2018
2 parents 8da6d12 + dbb0fe6 commit ba7a1df
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ There is zero configuration. Zero dependencies. Minifies to 435 bytes, and gzips

## Usage

Simply pass a unix timestamp, and get a time ago formated string.
Simply pass a unix timestamp *converted to milliseconds* (`timestamp * 1000`) and get a time ago formatted string.

The reason of converting is simple, the base unit of time in JavaScript is milliseconds(ms) while Unix Timestamp is in seconds. Therefore need to multiply Unix Timestamp by `1000` in order to get relative time.

```jsx
import timeAgo from 'epoch-timeago';

// Example of simple usage
const timeDiff = timeAgo(timestamp * 1000)

//Example of formatted string
const timeSince = timeAgo(Date.now() - 60000 * 10);
// '10 minutes ago'
```
Expand Down

0 comments on commit ba7a1df

Please sign in to comment.