Moment Js get current week start and end date example; In this tutorial we are going to share how to get current week start and end date using moment js. You can use to get start date and end date of current week in jquery, javascript vuejs, react any javascript framwork.
Moment Js gives us startOf() and endOf() methods to get current week start and end date. Let’s see the below syntax and example with output.
Syntax:
let startDate = moment().startOf('week'); let endDate = moment().endOf('week');
Example:
<!DOCTYPE html>
<html>
<head>
<title>moment js get current week start and end date</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>moment js get current week start and end date</h1>
</body>
<script type="text/javascript">
let startDate = moment().startOf('week');
let endDate = moment().endOf('week');
console.log('Start Date:' + startDate.format('MM/DD/YYYY'));
console.log('End Date:' + endDate.format('MM/DD/YYYY'));
</script>
</html>
Output:
Start Date:01/30/2022
End Date:02/05/2022
Hope this example help you.