1.1.5 • Published 5 years ago
date-format-simple v1.1.5
date-format-simple
simple JavaScript date library for formatting dates.
output
- a few seconds ago
- 30 seconds ago
- a minute ago
- 3 minutes ago
- an hour ago
- 5 hours ago
- a days ago
- 30 days ago
- a month ago
- 11 months ago
- a year ago
- 2 years ago
Install
$npm install date-format-simple
Usage
var DateFormat = require( 'date-format-simple' );
var today = new Date();
var myDate = new Date( 2015, 5, 10 );
var dateFormat = new DateFormat( today.getTime() );
dateFormat.print( myDate.getTime() );
dateFormat.toGMTDate( '2016-02-02T07:09:32.277Z' );
API
new DateFormat( milisecond, [options] );
var dateFormat = new DateFormat( milisecond );
dateFormat.print( milisecond );
options
var dateFormat = new DateFormat( 2016, 3, 10, {
'a_few_seconds_ago': 'just now',
'months_ago': 'months ago~ :D'
}, false, 'YYYY-MM-DD' );
// new DateFormat( date, msg, isGMT = false, dateFormat = 'YYYY-MM-DD' )
dateFormat.print( new Date( 2016, 1, 10 ) );
//result => 2 months ago~ :D
dateFormat.print( new Date( 2016, 3, 9, 23, 59, 59 ) );
//result => just now
default options
{
'a_few_seconds_ago': 'a few seconds ago',
'seconds_ago': 'seconds ago',
'a_minute_ago': 'a minute ago',
'minutes_ago': 'minutes ago',
'an_hour_ago': 'an hour ago',
'hours_ago': 'hours ago',
'a_day_ago': 'a day ago',
'days_ago': 'days ago',
'a_month_ago': 'a month ago',
'months_ago': 'months ago',
'a_year_ago': 'a year ago',
'years_ago': 'years ago'
}
build
- npm install babel -g
- npm run compile
Test
- npm install mocha -g
- npm test
License
© 2016 ingpdw. MIT License
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
6 years ago
1.1.2
6 years ago
1.1.1
7 years ago
1.1.0
8 years ago
1.0.28
8 years ago
1.0.27
8 years ago
1.0.26
8 years ago
1.0.25
8 years ago
1.0.24
8 years ago
1.0.23
8 years ago
1.0.21
8 years ago
1.0.20
8 years ago
1.0.18
8 years ago
1.0.17
8 years ago
1.0.16
8 years ago
1.0.15
8 years ago
1.0.14
8 years ago
1.0.13
8 years ago
1.0.12
8 years ago
1.0.11
8 years ago
1.0.9
8 years ago
1.0.8
8 years ago
1.0.7
8 years ago
1.0.6
8 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago
0.1.0
8 years ago