Jquery Moment Get Last Date Of Month Example
Hi Guys,
In this example,I will learn you how get last date of month in moment js.you can easy and simply get get last date of month in moment js.
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.
Example:
<!DOCTYPE html>
<html>
<head>
<title>jquery moment example - NiceSnippests.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 - NiceSnippests.com</h1>
</body>
<script type="text/javascript">
var startOfMonth = moment().clone().startOf('month').format('DD-MM-YYYY');
console.log(startOfMonth);
var endOfMonth = moment().clone().endOf('month').format('DD-MM-YYYY');
console.log(endOfMonth);
</script>
</html>
Output:
01-06-2021
30-06-2021
It will help you...
- How to Show Loading Spinner in JQuery?
- How to Create Ajax Submit Form Using jQuery?
- How To Get Current Page URL, Path, Host and hash using jQuery?
- How To Get, Set and Delete Div Background Image jQuery?
- JQuery Remove All Unwanted Whitespace From String Example
- Body Background Video Using Vide Jquery Example
- JQuery UI Autocomplete Example
- JQuery Split String By Comma Into Array Example