How To Get Next Year Date Using JavaScript?


Share:
Published By: Admin, Published On: Nov 27, 2021, Category: Javascript


Hello Friends,

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

Here i will give you many example how to get next year 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 Year Date Using JavaScript? - MyWebtuts.com</title>
    </head>
    <body>
        <h3>How To Get Next Year Date Using JavaScript? - MyWebtuts.com</h3>

        <script type="text/javascript">

            var nextYearDate = new Date(new Date().getFullYear(), 0, 1);
            nextYearDate.setFullYear(nextYearDate.getFullYear()+1);

            var getDate = nextYearDate.toLocaleString('en-US');

            document.write(getDate);

        </script>
    </body>
</html>
Output :
1/1/2022, 12:00: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 Year Date Using JavaScript? - MyWebtuts.com</title>
    </head>
    <body>
        <h3>How To Get Next Year Date Using JavaScript? - MyWebtuts.com</h3>

        <script type="text/javascript">

            var startYear = new Date(new Date().getFullYear()+1, 0, 1);
            var getDate = startYear.toLocaleString('en-US');

            document.write(getDate);

        </script>
    </body>
</html>
Output :
1/1/2022, 12:00:00 AM

It will help you...

Share: