S-ago

s-ago

Human readable relative times.

26 SLOC to convert Date objects into human readable relative timestamps, such as 7 minutes ago or yesterday or 2 days ago

Get it: npm install --save s-ago

Sample usage:

1
2
3
4
5
6
7
8
9
const ago = require('s-ago');

const now = new Date();
const yesterday = new Date(now - (24 * 60 * 60 * 1000));
const hoursAgo = new Date(now - (6 * 60 * 60 * 1000));

ago(now); // 'just now' 
ago(yesterday); // 'yesterday' 
ago(hoursAgo); // '6 hours ago' 

GIT FTW!

s-ago

Suggest a module

Comments