JavaScript Get month Name from Date

Get month name in javascript. Through this tutorial, i am going to show you how to get month name in javascript, get month name from date string in javascript, get previous month name in javascript, convert month number to month name in javascript and how to get month name from number in javascript.

How to get the month name from Date in JavaScript

  • 1. javascript get current month name
  • 2. javascript get month from date string
  • 3. javascript get previous month name
  • 4. get month name from number in javascript
  • 5. javascript get next month name

1. javascript get current month name

Use the following javaScript function to get the current month name in a string; as follows:

   function getCurrentMonthName(dt){
     monthNamelist = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
    return monthNamelist[dt.getMonth()];
   };

2. javascript get month from date string

Here, you will create function, which is used to return the month name from given date string in javascript:

   function getMonthNameDateString(dt){
     monthNamelist = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
    return monthNamelist[dt.getMonth()];
   };

3. javascript get previous month name

Use the following javaScript function to get the previous month name; as follows:

   function getPreviousMonthName(dt){
     monthNamelist = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
    return monthNamelist[dt.getMonth()-1];
   };

4. get month name from number in javascript

Here you will create a function for getting a month name from number in javascript. In this function, you will pass the month number between 0 to 11 and this function converts month number to month name using javascript.

Note 0 is jan, 1 is feb, 2 is march and so on.

   function getMonthNameNumber(number){
     monthNamelist = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
    return monthNamelist[number.getMonth()];
   };

5. javascript get next month name

Use the following javaScript function to get next month name using current date; as follows:

   function getNextMonthName(date){
     monthNamelist = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
    return monthNamelist[date.getMonth()+1];
   };

More JavaScript Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *