| Index | Code Tester |
Date Object
var dDate = new Date()alert(dDate)var dD1 = new Date("October 31, 2003 12:34:00") //can use this format without specifying timealert(dD1)var dD2 = new Date(1994, 0, 22)alert(dD2)var dD3 = new Date(2002, 11, 7, 9, 35, 23)alert(dD3)var dD4 = new Date(154456) //This is date that is 154456 milliseconds since January 1, 1970
var dD = new Date()alert(dD)dD.setYear(2010) //sets year to 2010alert(dD)alert(dD.getDate()) //gets dayalert(dD.getTime()) //# milliseconds since 1970
1. List the methods associated with the Date object.
2. Create a page and display the time in the status bar. Display only the hour and minutes. Do not hard-code the time.
3. Write a function that accepts a date object and returns which day of the week it is. For example, if the date is a 12/4/2003, the function should return Thursday. Hint, use getDay().
4. Create a function that accepts 2 dates and returns the number of days between them. Test your function.
5. Create a function that automatically generates a calender displaying the days in the current month.