How to get the day of the week in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To get the day of the week, use the JavaScript getDay() method. JavaScript date getDay() method returns the day of the week for the specified date according to local time. The value returned by getDay() is an integer corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.

Example

You can try to run the following code to get the day of the week in JavaScript −

Live Demo

<html>
   <head>
      <title>JavaScript getDay Method</title>
   </head>
   <body>
      <script>
         var dt = new Date("December 25, 1995 23:15:00");
         document.write("Day of the week: " + dt.getDay() );
      </script>
   </body>
</html>

Output

Day of the week: 1
raja
Published on 13-Feb-2018 08:29:29
Advertisements