Skip to content

Simple time ago function for node that actually works!

Notifications You must be signed in to change notification settings

thatisuday/npm-time-ago

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-time-ago Build Status npm downloads npm version npm dependencies

Simple time ago function for node.js that actually works!


npm install --save node-time-ago

Use timestamp, Date Instance, iso8601 date or any valid parsable date string as input.

var timeAgo = require('node-time-ago');

timeAgo(new Date()); // just now
timeAgo(Date().now()); // just now
timeAgo(new Date().toISOString()); // just now

timeAgo(Date.now() + 35 * 1000); // "35 second ago",
timeAgo(Date.now() + 65 * 1000); // "a minute ago",
timeAgo(Date.now() + 3 * 60 * 1000); // "3 minutes ago",
timeAgo(Date.now() + 65 * 60 * 1000); // "an hour ago",
timeAgo(Date.now() + 3 * 60 * 60 * 1000); // "3 hours ago",
timeAgo(Date.now() + 25 * 60 * 60 * 1000); // "a day ago",
timeAgo(Date.now() + 3 * 24 * 60 * 60 * 1000); // "3 days ago",
timeAgo(Date.now() + 35 * 24 * 60 * 60 * 1000); // "a month ago",
timeAgo(Date.now() + 3 * 30 * 24 * 60 * 60 * 1000); // "3 months ago",
timeAgo(Date.now() + 13 * 30 * 24 * 60 * 60 * 1000); // "a year ago",
timeAgo(Date.now() + 3 * 12 * 30 * 24 * 60 * 60 * 1000); // "3 years ago"

About

Simple time ago function for node that actually works!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published