from-now
Get relative time (ago) like 5 seconds, 12 hours, 3 months...
Install
$ npm install --save from-now
Usage
var fromNow = ; ;;;
API
fromNow(input, translations)
input
Type: string
, number
or date object
(everything that date constructor accept)
Time in past.
translations
Type: object
Default: {}
Custom translations that can be used for units.
Example
var fromNow = ;var opts = 'seconds': 1: 'sekunda' 2: 'sekundy' 5: 'sekund'; ;
It will match the nearest key that is smaller than interval.
1 second = 1 sekunda
2 seconds = 2 sekundy
3 seconds = 3 sekundy
4 seconds = 4 sekundy
5 seconds = 5 sekund
You can also use shorthand that will be used for all intervals.
var fromNow = ;var opts = 'seconds': 's'; ; // 15 s
Check the tests for more details.
License
MIT © Daniel Husar