How To Get Day 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 day name from date example.We will check how to get day name from date. This is a short guide on get day name from date in javascript. Here you will learn how to get javascript day name from date. Let's get started with how to get day name from date in javascript.

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

        <script type="text/javascript">

            let weekday = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][new Date().getDay()]

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

        <script type="text/javascript">

            let dayName = new Date().toLocaleString('en-us', {weekday:'long'});

            document.write(dayName);
            
        </script>
    </body>
</html>
Output :
Saturday

It will help you...

Share: