Skip to content

Formats JavaScript dates to relative time strings (e.g., "3 hours ago")

License

Notifications You must be signed in to change notification settings

rxaviers/relative-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Relative Time

Formats JavaScript dates to relative time strings (e.g., "3 hours ago").

Based on the Unicode CLDR locale data. Powered by jquery/globalize.

Usage

npm install --save relative-time globalize cldr-data
var cldrData = require("cldr-data");
var Globalize = require("globalize");
var RelativeTime = require("relative-time");

// Feed Globalize on CLDR.
Globalize.load(cldrData.entireSupplemental(), cldrData.entireMainFor("en"));
Globalize.locale("en");

var relativeTime = new RelativeTime();
console.log(relativeTime.format(new Date()));
// > now

License

MIT © Rafael Xavier de Souza

About

Formats JavaScript dates to relative time strings (e.g., "3 hours ago")

Resources

License

Stars

Watchers

Forks

Packages