How to Get Next Month Date in Moment JS?
Hello Guys,
Now let's see example of how to get next month date using momentjs. This article will give you simple example of momentjs get next month date. We will show how to get next month date from current date in momentjs.
Moment.js provides a wrapper for the native JavaScript date object. I will learn how to get next month date in jquery moment.
Here I will give full example for jquery moment get next month date. So let's see below example:
Example :
<!DOCTYPE html>
<html>
<head>
<title>How to Get Next Month Date in Moment JS? - NiceSnippets.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>How to Get Next Month Date in Moment JS? - NiceSnippets.com</h1>
<script type="text/javascript">
var nextMonthDate = moment().add(1, 'months').format('DD-MM-YYYY');
console.log(nextMonthDate);
var startDateTime = '03-06-2021'
var nextMonthDate = moment(startDateTime, "DD-MM-YYYY")
.add(1, 'months')
.format('LL');
console.log(nextMonthDate);
var nextMonthName = moment(startDateTime, "DD-MM-YYYY")
.add(1, 'months')
.format('MMMM');
console.log(nextMonthName);
</script>
</body>
</html>
Output
03-07-2021
July 3, 2021
July
It will help you....
- How to set Date in setUTCHours() Method in JavaScript?
- How to Date sets UTC milliseconds in Javascript?
- How to Use push(), unshift(),pop() and shift() With Array in Javascript?
- How to Check if a Variable is a Number in Javascript?
- How To Format a Number Using Fixed - Point Notation in Javascript?
- How to Insert an Element into an Array in javaScript?
- How to remove duplicate elements from JavaScript Array?
- How to calculate years, months and days between two dates in javascript?