Javascript Date getShortMonthName()

Description

Javascript Date getShortMonthName()


Date.prototype.monthNames = [
  "January",/*from   ww  w  . jav  a2  s .c o  m*/
  "February",
  "March",
  "April",
  "May",
  "June",
  "July",
  "August",
  "September",
  "October",
  "November",
  "December"
];

// class methods

Date.getMonthName = function (month) {
  return Date.prototype.monthNames[month];
};

Date.getShortMonthName = function (month) {
  return Date.getMonthName(month).substr(0, 3);
};

// instance methods

Date.prototype.getMonthName = function() {
  return this.monthNames[this.getMonth()];
};

Date.prototype.getShortMonthName = function () {
  return this.getMonthName().substr(0, 3);
};

Javascript Date monthNames = [

Date.prototype.monthNames = [
    "January", "February", "March",
    "April", "May", "June",
    "July", "August", "September",
    "October", "November", "December"
];

Date.prototype.getMonthName = function() {
    return this.monthNames[this.getMonth()];
};

Date.prototype.getShortMonthName = function () {
    return this.getMonthName().substr(0, 3);
};

Date.sameDays = function (dateA, dateB) {
  return (dateA.getFullYear() === dateB.getFullYear() &&
          dateA.getMonth() === dateB.getMonth() &&
          dateA.getDay() === dateB.getDay());
}



PreviousNext

Related