neatime

1.0.0 • Public • Published

neatime npm bower

Returns a simple relative time string.

Usage Examples

// within the last minute
neatime(new Date()-1e4) == 'Just now'
 
// within the last hour
neatime(Date.now()-1e6) == '16m'
 
// within the last hour
neatime(Date.now()-1e7) == '2h'
 
// within the last 7 days
neatime('Dec 31, 2014') == '4d'
 
// over 7 days ago gives a simple date
neatime('July 20, 2015') == 'Jul 20'
 
// over half a year ago adds the year
neatime('July 4, 2014') == 'Jul 4, 2014'

License

WTFPL

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i neatime

      Weekly Downloads

      5

      Version

      1.0.0

      License

      WTFPL

      Last publish

      Collaborators

      • developit