Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

JavaScript getDay Function

by suresh

JavaScript getDay function is one of the Date Function, which is used to return the Day number from given date. The value returned by this getDay number will be : 0 is Sunday, 1 is Monday, 2 is Tuesday etc.

In this article, we will show you, How to use Get Day in JavaScript Programming with an example.

JavaScript getDay Function Example

The following example helps you understand the JavaScript get Day Function.

Here, we are using getDay to return day number (Day of the Week number) from the current date and time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Date Functions </title>
</head>
<body>
    <h1> JavaScript getDay Function Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time :  " + dt);
  document.write("Day from getDay(): " + dt.getDay());
</script>
</body>
</html>

OUTPUT

JavaScript getDay Function 1

JavaScript get Day Function Example

In this JavaScript getDay function example, we are extracting day number from the custom date

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Date Functions </title>
</head>
<body>
    <h1> JavaScript getDay Function Example </h1>
<script>
  var dt = Date("January 22, 2014 10:09:07");
  document.write("Date and Time : " + dt);
  document.write("Day from getDay(): " + dt.getDay());
</script>
</body>
</html>

OUTPUT

JavaScript getDay Function 2

Placed Under: JavaScript

Stay in Touch!

Sign Up to receive Email updates on Latest Tutorials

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy