Date
The Date constructor can be used with several types of input:
You can pass values for year, month, date of the month, hour, minute, second and millisecond, like so:
>>> new Date(2011, 0, 1, 13, 30, 35, 500)
Sat Jan 01 2011 13:30:35 GMT-0800 (Pacific Standard Time)
You can skip any of the input parameters, in which case they are assumed to be 0. Note that month values are from 0 (January) to 11 (December), hours are from 0 to 23, minutes and seconds 0 to 59, and milliseconds 0 to 999.
You can pass a timestamp:
>>> new Date(1293917435500)
Sat Jan 01 2011 13:30:35 GMT-0800 (Pacific Standard Time)
If you don't pass anything, the current date/time is assumed:
>>> new Date()
Fri Apr 18 2008 01:13:00 GMT-0700 (Pacific Daylight Time)
If you pass a string, it's parsed in attempt to extract a possible date value:
>>> new Date('May 4, 2008')Sun May 04 2008 00:00:00 GMT-0700 (Pacific Daylight Time)
Members of the Date Constructor
|
Property/Method |
Description |
|---|---|
| ... |