How To Get Month Name From Date In JavaScript?


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


Hello Friends,

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

Here i will give you many example how to get month name from 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 Month Name From Date In JavaScript? - MyWebtuts.com</title>
    </head> 
    <body>  
        <h3>How To Get Month Name From Date In JavaScript? - MyWebtuts.com</h3>

        <p id="demo"></p>

        <script type="text/javascript">

            const date = new Date(2009, 10, 10);
            const month = date.toLocaleString('default', { month: 'long' });

            document.write(month);
                
        </script>
    </body>
</html>
Output :
November
Example : 2
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>How To Get Month Name From Date In JavaScript? - MyWebtuts.com</title>
    </head>
    <body>
        <h3>How To Get Month Name From Date In JavaScript? - MyWebtuts.com</h3>

        <script type="text/javascript">

            const date = new Date(2009, 10, 10);
            const month = date.toLocaleString('default', { month: 'short' });

            document.write(month);
            
        </script>
    </body>
</html>
Output :
Nov
Example : 3
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>How To Get Month Name From Date In JavaScript? - MyWebtuts.com</title>
    </head> 
    <body>  
        <h3>How To Get Month Name From Date In JavaScript? - MyWebtuts.com</h3>

        <p id="demo"></p>

        <script type="text/javascript">

            const date = new Date();
            const month = date.toLocaleString('default', { month: 'long' });

            document.write(month); 
            
        </script>
    </body>
</html>
Output :
December
Example : 4
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>How To Get Month Name From Date In JavaScript? - MyWebtuts.com</title>
    </head> 
    <body>  
        <h3>How To Get Month Name From Date In JavaScript? - MyWebtuts.com</h3>

        <p id="demo"></p>

        <script type="text/javascript">

            const date = new Date();
            const month = date.toLocaleString('default', { month: 'short' });

            document.write(month); 
                
        </script>
    </body>
</html>
Output :
Dec

It will help you...

Share: