The Date object's properties and methods are described below:
NN: Netscape, IE: Internet Explorer
Properties
Syntax: object.property_name
| Property | Description | NN | IE |
|---|---|---|---|
| constructor | Contains the function that created an object's prototype | 4 | 4 |
| prototype | Allows addition of properties to a date | 3 | 4 |
Methods
Syntax: object.method_name()
| Method | Description | NN | IE |
|---|---|---|---|
| Date() | Returns a Date object | 2 | 3 |
| getDate() | Returns the date of a Date object (from 1-31) | 2 | 3 |
| getDay() | Returns the day of a Date object (from 0-6. 0=Sunday, 1=Monday, etc.) | 2 | 3 |
| getMonth() | Returns the month of a Date object (from 0-11. 0=January, 1=February, etc.) | 2 | 3 |
| getFullYear() | Returns the year of a Date object (four digits) | 4 | 4 |
| getYear() | Returns the year of a Date object (from 0-99). Use getFullYear instead !! | 2 | 3 |
| getHours() | Returns the hour of a Date object (from 0-23) | 2 | 3 |
| getMinutes() | Returns the minute of a Date object (from 0-59) | 2 | 3 |
| getSeconds() | Returns the second of a Date object (from 0-59) | 2 | 3 |
| getMilliseconds() | Returns the millisecond of a Date object (from 0-999) | 4 | 4 |
| getTime() | Returns the number of milliseconds since midnight 1/1-1970 | 2 | 3 |
| getTimezoneOffset() | Returns the time difference between the user's computer and GMT | 2 | 3 |
| getUTCDate() | Returns the date of a Date object in universal (UTC) time | 4 | 4 |
| getUTCDay() | Returns the day of a Date object in universal time | 4 | 4 |
| getUTCMonth() | Returns the month of a Date object in universal time | 4 | 4 |
| getUTCFullYear() | Returns the four-digit year of a Date object in universal time | 4 | 4 |
| getUTCHours() | Returns the hour of a Date object in universal time | 4 | 4 |
| getUTCMinutes() | Returns the minutes of a Date object in universal time | 4 | 4 |
| getUTCSeconds() | Returns the seconds of a Date object in universal time | 4 | 4 |
| getUTCMilliseconds() | Returns the milliseconds of a Date object in universal time | 4 | 4 |
| parse() | Returns a string date value that holds the number of milliseconds since January 01 1970 00:00:00 | 2 | 3 |
| setDate() | Sets the date of the month in the Date object (from 1-31) | 2 | 3 |
| setFullYear() | Sets the year in the Date object (four digits) | 4 | 4 |
| setHours() | Sets the hour in the Date object (from 0-23) | 2 | 3 |
| setMilliseconds() | Sets the millisecond in the Date object (from 0-999) | 4 | 4 |
| setMinutes() | Set the minute in the Date object (from 0-59) | 2 | 3 |
| setMonth() | Sets the month in the Date object (from 0-11. 0=January, 1=February) | 2 | 3 |
| setSeconds() | Sets the second in the Date object (from 0-59) | 2 | 3 |
| setTime() | Sets the milliseconds after 1/1-1970 | 2 | 3 |
| setYear() | Sets the year in the Date object (00-99) | 2 | 3 |
| setUTCDate() | Sets the date in the Date object, in universal time (from 1-31) | 4 | 4 |
| setUTCDay() | Sets the day in the Date object, in universal time (from 0-6. Sunday=0, Monday=1, etc.) | 4 | 4 |
| setUTCMonth() | Sets the month in the Date object, in universal time (from 0-11. 0=January, 1=February) | 4 | 4 |
| setUTCFullYear() | Sets the year in the Date object, in universal time (four digits) | 4 | 4 |
| setUTCHours() | Sets the hour in the Date object, in universal time (from 0-23) | 4 | 4 |
| setUTCMinutes() | Sets the minutes in the Date object, in universal time (from 0-59) | 4 | 4 |
| setUTCSeconds() | Sets the seconds in the Date object, in universal time (from 0-59) | 4 | 4 |
| setUTCMilliseconds() | Sets the milliseconds in the Date object, in universal time (from 0-999) | 4 | 4 |
| toGMTString() | Converts the Date object to a string, set to GMT time zone | 2 | 3 |
| toLocaleString() | Converts the Date object to a string, set to the current time zone | 2 | 3 |
| toString() | Converts the Date object to a string | 2 | 4 |
博客介绍了Date对象的属性和方法。提到属性的语法为object.property_name,方法的语法为object.method_name(),还给出了Netscape(NN)和Internet Explorer(IE)相关说明。
995

被折叠的 条评论
为什么被折叠?



