Learn free online HTML5, javascript, and jquery Tutorials by Examples

Wednesday, 18 June 2014

Dynamic Date Display in javascript

--------------------------------------------------
<script>

var day = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var month = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var now = new Date();
//alert(now)
// getDay() -- day of the week (a number between 0 - 6)
// getMonth() -- month of the year (a number between 0 - 11)
// getDate() -- day of the month (a number between 1 - 31)
document.write("<H1>Today is " +
                          day[now.getDay()] + ", " +
                          month[now.getMonth()] + " " +
                          now.getDate() + ".</H1>")
</script>


--------------------------------------------------

No comments:

Post a Comment