fuzzy-time
v1.0.7
Published
A simple timeago to update timestamp (e.g 4 days 12 hours 4 minutes ago) with no dependencies
Downloads
33
Maintainers
Readme
fuzzy-time
A simple timeago to update timestamp (e.g 4 days 12 hours 4 minutes ago) with no dependencies
Usage:
to install
npm install fuzzy-time
As node modules
var fuzzyTime = require('fuzzy-time')
console.log(fuzzyTime('2016-01-09 23:16'))
Usage for browser look in dist folder
<script src="node_modules/fuzzy-time/dist/fuzzy-time.min.js"></script>
<script>
var fuzzyTime = window.fuzzyTime;
console.log(fuzzyTime('2016-01-09 23:16'))
</script>
Options Paramenters
fuzzyTime(date, options)
- setMinDays: set the minimum days before the date is shown as actual date
- days: change the days string
- hours: change the hours string
- minutes: change the minutes string
- on: change the on string
- setMonthArray: Set New Array for Month ( eg: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'])
- dateFormat: date format, can be set to 'simple' format which output ( eg: July 20 '15)
Sample Usage with Options
var opts = {
setMinDays: 4,
days: 'hari',
hours: 'jam',
minutes: 'minit lepas',
on: 'pada',
setMonthArray: [
'Januari',
'Februari',
'Mac',
'April',
'Mei',
'Jun',
'Julai',
'Ogos',
'September',
'Oktober',
'November',
'Disember'
],
dateFormat: 'simple'
}
var getDate = fuzzyTime('2015-12-27 23:16', opts)
console.log(getDate)