API Docs for: 2.5.3
Show:

Date Class

Defined in: src/Helpers/date.js:1

Extension of 'Date' class

Item Index

Methods

getMonthName

(
  • month
)
String

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:

  • month Number

    Represents a month on a zero-indexed, 12-month calendar.

Returns:

String:

Abbreviated month name

getTimeAgoFormat

(
  • date
  • [options]
  • [options]
)
String

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:

  • date Date

    data.

  • [options] String optional

    langCode. (ko/en/zh, en: default code)

  • [options] Object optional

    customTimeData if langCode == custom, use custom time data.

Returns:

String:

time-ago string format