Moment JS Get Month Name from Number Example

By Hardik Savani January 2, 2021 Category : jQuery

Hi,

This tutorial is focused on moment get month name from number. This post will give you simple example of jquery moment get month name from number. let’s discuss about moment js get month name from number. In this article, we will implement a how to get month name from month number in jquery.

Here, i will give you simple example of jquery moment js format() method with 'MMMM' that will provide you month name from number.

let's see both example with output:

Example

<!DOCTYPE html>

<html>

<head>

<title>jquery moment example - ItSolutionStuff.com</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" crossorigin="anonymous"></script>

</head>

<body>

<h1>jquery moment example - ItSolutionStuff.com</h1>

</body>

<script type="text/javascript">

var monthName = moment('10', 'MM').format('MMMM');

console.log(monthName);

</script>

<script type="text/javascript">

var startDateTime = '26-12-2020'

var monthName = moment(startDateTime, "DD-MM-YYYY")

.format('MMMM');

console.log(monthName);

</script>

</html>

Output:

October

December

I hope it can help you...

Tags :
Shares