How to Get Next Month Date in Moment JS?

By Hardik Savani January 2, 2021 Category : jQuery

Hello,

This example is focused on how to get next month date in moment js. This article will give you simple example of moment js get next month date. i would like to share with you jquery moment get next month. This article goes in detailed on how to get next month in jquery moment. So, let's follow few step to create example of moment get next month.

Here, i will give you simple example of jquery moment js add() method provide you last next month date.

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 nextMonthDate = moment().add(1, 'months').format('MM-DD-YYYY');

console.log(nextMonthDate);

</script>

<script type="text/javascript">

var startDateTime = '01-01-2021'

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

.add(1, 'months')

.format('MM/YYYY');

console.log(nextMonthDate);

</script>

</html>

Output:

02-02-2021

02/2021

I hope it can help you...

Tags :
Shares