Moment Get Current Week Number Example

Jquery

Nicesnippets

9684

25-04-2021


Hi Guys,

Now let's see example of how to get current week number using momentjs in jquery. We will talk about momentjs get current week number example using jquery. In This article will give you example of moment get current week number. I’m going to show you about how to get current week number in moment js.

Here, i will give you simple example of jquery moment js get current week number using week().

So let's see both example with output:

Example


<!DOCTYPE html>

<html>

<head>

<title>jquery moment example - 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>jquery moment example - NiceSnippets.com</h1>

</body>

<script type="text/javascript">

var weekNumber = moment('02-04-2021', 'DD-MM-YYYY').week();

console.log(weekNumber);

var weekNumber = moment().week();

console.log(weekNumber);

</script>

</html>

Output :

4

2

It will help you....


Recommended Posts