Display the current day of the week java Script
We can display the present day of the week by using getDay function. getDay function will return 0 to 6 based on the day
Example
Sunday - returns 0
Monday - returns 1
Tuesday - returns 2
Wednesday - returns 3
Thursday - returns 4
Friday - returns 5
Saturday - returns 6
Code example results
Copy and paste the following code into your source code
Example
Sunday - returns 0
Monday - returns 1
Tuesday - returns 2
Wednesday - returns 3
Thursday - returns 4
Friday - returns 5
Saturday - returns 6
Code example results
Copy and paste the following code into your source code
<script language = "JavaScript">
var now = new Date();
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
document.write("Today is " + dayNames[now.getDay()] + ".");
</script>
Display the current day of the week java Script
Reviewed by Unknown
on
1:37 PM
Rating:
No comments: