HTML and CSS Reference
In-Depth Information
Figure 11-8
retrieving values from a date object
var thisDate = new Date("July 22, 2015 14:35:28")
Method
Retrieves
Value
thisDate.getSeconds()
the seconds value
28
thisDate.getMinutes()
the minutes value
35
thisDate.getHours()
the hours value (in 24-hour time)
14
thisDate.getDate()
the day of the month value
22
thisDate.getDay()
the day of the week value (0 = Sunday,
1 = Monday, 2 = Tuesday, 3 = Wednesday,
4 = Thursday, 5 = Friday, 6 = Saturday)
3
thisDate.getMonth()
the month value (0 = January, 1 = February,
2 = March, etc.)
6
thisDate.getFullYear()
the four-digit year value
2015
thisDate.getTime()
the time value, as expressed in milliseconds,
since January 1, 1970 at 12:00 a.m.
1,437,593,728,000
Retrieving Date and Time Values
• To retrieve the year value from a Date object, use the method
date .getFullYear()
where date is a Date object.
• To retrieve the month value, use the method
date .getMonth()
where a month value of 0 equals the first month of the year (January), a month value
of 1 equals the second month of the year (February), and so forth.
• To retrieve the day of the month value, use the following method:
date .getDate()
• To retrieve the day of the week value, use the method
date .getDay()
where a value of 0 equals the first weekday (Sunday), a value of 1 equals the second
weekday (Monday), and so forth.
• To retrieve the hours value, use the following method:
date .getHours()
• To retrieve the minutes value, use the following method:
date .getMinutes()
• To retrieve the seconds value, use the following method:
date .getSeconds()
Search WWH ::




Custom Search