https://github.com/developit/neatime
Returns a simple relative time string.
https://github.com/developit/neatime
Last synced: 6 months ago
JSON representation
Returns a simple relative time string.
- Host: GitHub
- URL: https://github.com/developit/neatime
- Owner: developit
- Created: 2015-08-03T15:45:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-17T06:35:13.000Z (over 8 years ago)
- Last Synced: 2025-06-20T20:01:17.310Z (6 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 30
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
neatime [![npm]](http://npm.im/neatime) [![bower]](http://bower.io/search/?q=neatime) [![travis]](https://travis-ci.org/developit/neatime)
=======
Returns a simple relative time string.
Usage Examples
--------------
```js
// 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
[npm]: https://img.shields.io/npm/v/neatime.svg
[bower]: https://img.shields.io/bower/v/neatime.svg
[travis]: https://img.shields.io/travis/developit/neatime.svg