Get Month Name In Javascript

Month Name in JavaScript.
Get Month Name Javascript.
Javascript Date Object, Months Names.

There's a very simple way to get the month's name in javascript.  The only problem is, that people do it over and over instead of just placing this in the Date object.

Do, the solution is rather simple:

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

Next time you'll want to get a name you can just:
      var month_Name = new Date().getMonthName();

Sometime in the near future I'll upload a file with all of my extensions to Javascript's Array and Date objects.

Elad Shalom,
CTO at


  1. You can leave out the var and just return [...][this.getMonth()

  2. You can, but in case of JS Error you'll get hard times finding the exact error. Plus, when you learn new things, you'd better put everything as simple as possible. Worry about optimization later :)

  3. var d= new date(); alert(d.getMonth);
    This script is giving me wrong month for instance if today is month 9(September) but this script giving me 8(august) so in result I am receiving wrong month. please tell me what should I do?

  4. Welcome to Packers And Movers Bangalore are the explorer in Packing and Moving industry,
    offering 100% of quality and safe moving services.Agarwal Packers Bangalore

    Agarwal Packers And Movers Provide Best Service For house shifting
    Office Shifting Services in Bangalore while focusing on clients satisfaction.Agarwal Movers Packers

    We are one of the specialists in local shifting Bike Transport Service
    service and Local office shifting servicesNear Me Packers

    A local shifting household Shifting inside the located limits from the origin to the final destination.
    Agarwal Packers And Movers Movers And Packers Near Me
    Bangalore offers a wide variety of moving services,Packers And Movers Near Me

    from Commercial House Office moves for small and large Agarwal Safe Home Packers
    companies to residential moves for homes and apartments.Gati Packers Mover

    We provide local moves within Bangalore as well as long distance moves to all cities in and abroad.
    We also provide a storage facility for short and long terms.Movers And Packers Near Me

    India is one of The Best and Top most Packers And Movers Service Provider Company
    To shift or relocate the goods of the customers in Bangalore, India.Near Me Logistics And Packers

    past many years and now our packers and Movers Company become the best and top Packers and Movers in Bangalore,India.


Post a Comment

Popular posts from this blog

Protecting Personal Data

Linked Files in Visual Studio 2010

BDD, TDD, and Everything Between