How To Get Next Monday Date In JavaScript?


Share:
Published By: Admin, Published On: Dec 08, 2021, Category: Javascript


Hello Friends,

Now let's see example of how to get next monday date example. We will check how to get next monday date. This is a short guide on get next monday date in javascript. Here you will learn how to get next monday date. Let's get started with how to get next monday date in javascript.

Here i will give you many example how to get next monday date using javascript.

Example : 1
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>How To Get Next Monday Date In JavaScript? - MyWebtuts.com</title>
    </head> 
    <body>  
        <h3>How To Get Next Monday Date In JavaScript? - MyWebtuts.com</h3>

        <script type="text/javascript">
            
            var mondayDt = new Date('2021-12-14');
            mondayDt.setDate(mondayDt.getDate() + (((1 + 7 - mondayDt.getDay()) % 7) || 7));
            
            var getMonDt = mondayDt.toLocaleString('en-US');
            
            document.write(getMonDt);

        </script>
    </body>
</html>
Output :
12/20/2021, 5:30:00 AM
Example : 2
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>How To Get Next Monday Date In JavaScript? - MyWebtuts.com</title>
    </head> 
    <body>  
        <h3>How To Get Next Monday Date In JavaScript? - MyWebtuts.com</h3>

        <script type="text/javascript">

            var mondayDt = new Date();
            mondayDt.setDate(mondayDt.getDate() + (((1 + 7 - mondayDt.getDay()) % 7) || 7));

            var getMonDt = mondayDt.toLocaleString('en-US');

            document.write(getMonDt);

        </script>
    </body>
</html>
Output :
12/13/2021, 5:19:58 PM
Example : 3
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>How To Get Next Monday Date In JavaScript? - MyWebtuts.com</title>
    </head> 
    <body>  
        <h3>How To Get Next Monday Date In JavaScript? - MyWebtuts.com</h3>

        <script type="text/javascript">

            var days =[1,7,6,5,4,3,2];
            var monDt = new Date();
            monDt.setDate(monDt.getDate()+days[monDt.getDay()]);

            var getMonDt = monDt.toLocaleString('en-US');
            
            document.write(getMonDt);
            
        </script>
    </body>
</html>
Output :
12/13/2021, 5:21:10 PM

It will help you...

Share: