Date Object Methods
________________________________________Method Description
________________________________________
getYear() Year minus 1900
getMonth() Month of Year (Jan = 0)
getDate() Date within the month
getDay() Day of week (sun = 0)
getHours() Hour of 24-hr day
getMinutes() Minutes of hour
getSeconds() Seconds within minute
getTime() Milliseconds since 1/1/70
________________________________________
setYear() Year minus 1900
setMonth() Month of Year (Jan = 0)
setDate() Date within the month
setDay() Day of week (sun = 0)
setHours() Hour of 24-hr day
setMinutes() Minutes of hour
setSeconds() Seconds within minute
setTime() Milliseconds since 1/1/70
________________________________________
getTimezoneOffset() Minutes offset from GMT
toGMTString() String in universal format
getLocalString() String in system's format
parse("string") String to milliseconds
UTC(value) Date from GMT
The 5 ways to create a Date object for a specific date and time are shown below:
new Date("Month dd, yyyy hh:mm:ss")
new Date("Month dd, yyyy") new
Date(yy,mm,dd,hh,mm,ss) new
Date(yy,mm,dd) new Date(milliseconds)
Here is a example of creating a Date object for each of the 5 ways:
var myDateTime = new Date("May 1, 1999 12:00:00")
var myDateTime = new Date("May 1, 1999")
var myDateTime = new Date(99,04,01,12,00,00)
var myDateTime = new Date(99,04,01)
var myDateTime = new Date(100)
It is important to realize that all time in JavaScript is referenced to midnight, January 1, 1970, Greenwich Mean Time.
No comments:
Post a Comment