Converts a month integer to a month name - Node.js Date

Node.js examples for Date:Month

Description

Converts a month integer to a month name

Demo Code


/**//from w  ww.j  a  v a2  s .c  o  m
 * Date.getMonthName()
 * converts a month integer to a month name
 *
 * @index
 *    an integer between 0-11 representing a month of the year
 */
Date.prototype.getMonthName = function(index) {

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

  return array[index];

};

Related Tutorials