Date Class
Extension of 'Date' class
Item Index
Methods
Methods
getMonthName
(
String
-
month
Converts a numerical index to its corresponsing abbreviated string representation.
var a = Date.getMonthName(0);
var b = Date.getMonthName(1);
var c = Date.getMonthName(13);
// a ==> 'Jan'
// b ==> 'Feb'
// c ==> 'Feb'
Parameters:
-
monthNumberRepresents a month on a zero-indexed, 12-month calendar.
Returns:
String:
Abbreviated month name
getTimeAgoFormat
(
String
-
date -
[options] -
[options]
Converts a date data to time-ago string format.
var a = Date.getTimeAgoFormat(new Date());
var b = Date.getTimeAgoFormat(1474040255235);
var c = Date.getTimeAgoFormat(new Date(), 'zh');
var d = Date.getTimeAgoFormat(1474040255235, 'zh');
var e = Date.getTimeAgoFormat(1474040255235, 'custom', {
useBlank: true,
timeString: {
now: 'nowC',
suffix: 'agoC'
},
timeFormats: [
[60, 'secondsC', 1], // 60
[3600, 'minutesC', 60], // 60*60, 60
[86400, 'hoursC', 3600], // 60*60*24, 60*60
[604800, 'daysC', 86400], // 60*60*24*7, 60*60*24
[2419200, 'weeksC', 604800], // 60*60*24*7*4, 60*60*24*7
[29030400, 'monthsC', 2419200], // 60*60*24*7*4*12, 60*60*24*7*4
[2903040000, 'yearsC', 29030400] // 60*60*24*7*4*12*100, 60*60*24*7*4*12
]
});
// a ==> 'now'
// b ==> '1 months ago'
// c ==> '现在'
// d ==> '1个月前'
// e ==> '1 monthsC agoC'
Parameters:
-
dateDatedata.
-
[options]String optionallangCode. (ko/en/zh, en: default code)
-
[options]Object optionalcustomTimeData if langCode ==
custom, use custom time data.
Returns:
String:
time-ago string format
