Last Updated: February 25, 2016
·
2.712K
· geetotes

Get full name of a month from a Javascript date object

Extend the Date object with this handy method:

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

Now you can use dFoo.getMonthName() to return more than just a zero-based # of the month on your dates!!

<feel free to add dating puns to the comments/>

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#javascript
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside