Javascript Date getMonthName()

Description

Javascript Date getMonthName()


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


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

Javascript Date getMonthName()

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);
};

Javascript Date getMonthName()

Date.prototype.getMonthName = function() {
 var m = ['January','February','March','April','May','June','July',
          'August','September','October','November','December'];
 return m[this.getMonth()];
}

Date.prototype.getDayName = function() {
 var d = ['Sunday','Monday','Tuesday','Wednesday',
          'Thursday','Friday','Saturday'];
 return d[this.getDay()];
}

Date.prototype.format = function() {
 var d = new Date();
 var curr_date = d.getDate();
 var curr_month = d.getMonth();
 var curr_year = d.getFullYear();
 return (curr_date + "/" + curr_month + "/" + curr_year);
}

Javascript Date getMonthName()

Date.prototype.getMonthName = function(){
  return {//from   w w w .  j a  v a  2  s  . c  o  m
      0: 'January',
      1: 'February',
      2: 'March',
      3: 'April',
      4: 'May',
      5: 'June',
      6: 'July',
      7: 'August',
      8: 'September',
      9: 'October',
     10: 'November',
     11: 'December'
  }[this.getMonth()];
};

Javascript Date getMonthName()

monthName = ['January','February','March','April','May','June','July',
    'August','September','October','November','December'];

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

nDaysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

function numberOfDaysInMonth(year, month)
{
    if (month != 1)
        return nDaysInMonth[month]
    else /*w  w  w .  ja  v a2  s.  c  om*/
    {
        year = parseInt(year)
        if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
            return 29
        else return 28
    }
}

Date.prototype.getNumberOfDaysInMonth = function()
{
    var month = this.getMonth()
    var year = this.getYear()
    return numberOfDaysInMonth(year, month)        
}

Javascript Date getMonthName()

Date.prototype.getMonthName = function() {
 var m = ['January','February','March','April','May','June','July','August','September','October','November','December'];
 return m[this.getMonth()];
};



PreviousNext

Related