|
17 Date-Time
Date
object
-------------------------
date is kept as milliseconds since GMT Jan 1, 1970 (is stored as ms)
before that is negative time
JavaScript is always local time from user
's computer
GMT is 5 hours ahead of Eastern time
GMT is same as UTC
MyDate
=
new
date()
// MyDate is automatically set to current date and time
5 versions of date syntax
mydate
=
new
date(
"month dd, yyyy hh:mm:ss"
)
mydate
=
new
date(
"month dd, yyyy"
)
mydate
=
new
date(
"yyyy, mth, dd, hh, mm ss"
)
mydate
=
new
date(
"yy, mth, dd"
)
mydate
=
new
date(ms)
---------
Date
Object
Properties and Methods
---------------------------------------------------------------------
Properties
none
Methods
getDate
// day of month 0-31
getDay
getHours
// 0 - 23 0 is midnight
getMinutes
// 0 - 59
getMonth
// 0 - 11
getSeconds
// 0 - 59
getMilliseconds
// 0 - 999
getTime
// milliseconds since Jan 1, 1970, GMT
getTimeZoneOffset
getYear
// 2 digit (browser dependent - dont' use)
getFullYear
// 1999, 2000, ...
setData
setHours
setMinutes
setMonth
setSeconds
setTime
setYear
document.write (MyDate)
----->
Thu Aug 23 03
:
02
:
01 EDT 2001
|