ItSolutionStuff.com

Moment JS Get Last Date of Month Example

By Hardik Savani • January 2, 2021
jQuery

Hi,

This example is focused on moment js get last date of month. if you want to see example of moment js get first date of month then you are a right place. i explained simply about moment js get last day of month. you can see jquery moment get last date of month example. you will do the following things for how to get last date of month in jquery moment.

Here, i will give you simple example of jquery moment js startOf() method and endOf() method provide you last date and first date of month.

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 startOfMonth = moment().clone().startOf('month').format('YYYY-MM-DD');

console.log(startOfMonth);

</script>

<script type="text/javascript">

var endOfMonth = moment().clone().endOf('month').format('YYYY-MM-DD');

console.log(endOfMonth);

</script>

</html>

Output:

2021-01-01

2021-01-31

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Jquery Moment Convert String to Date Example

Read Now →

JQuery Moment Add Seconds to Datetime Example

Read Now →

JQuery Moment Add Hours to Datetime Example

Read Now →

JQuery Moment Subtract Minutes to Datetime Example

Read Now →

JQuery Moment Add Year to Date Example

Read Now →

JQuery Moment Add Days to Date Example

Read Now →

JQuery Moment Get Current Date Example

Read Now →

How to Install and Use Moment JS in Laravel?

Read Now →

How to Change Date Format using Moment in Vue JS?

Read Now →

How to Change Date Format in JQuery?

Read Now →