JavaScript getDay function is one of the Date Function, which is used to return the Day number from a given date. The value returned by this getDay number will be : 0 is Sunday, 1 is Monday, 2 is Tuesday, etc.
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 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