JavaScript Date object
The Date object
Date objects are used to process dates and times.
Create a Date object: new Date().
There are four ways to create a Date object as well:
var d =new Date( milliseconds );
var d =new Date( dateString );
var d =new Date( year , month , day , hours , minutes , seconds , milliseconds );
For a fuller date and actual tutorial, refer to the JavaScript Date Object tutorial.
Date object properties
Property | Describe |
---|---|
constructor | Returns a reference to the Date function that created this object. |
prototype | Gives you the ability to add properties and methods to objects. |
The Date object method
Method | Describe |
---|---|
getDate() | Returns a day of the month (1 to 31) from the Date object. |
getDay() | Returns a day of the week (0 to 6) from the Date object. |
getFullYear() | The year is returned in four digits from the Date object. |
getHours() | Returns the hour of the Date object (0 to 23). |
getMilliseconds() | Returns the date object's milliseconds (0 to 999). |
getMinutes() | Returns the minutes of the Date object (0 to 59). |
getMonth() | Returns the month (0 to 11) from the Date object. |
getSeconds() | Returns the number of seconds (0 to 59) of the Date object. |
getTime() | Returns the number of milliseconds from January 1, 1970 to the present. |
getTimezoneOffset() | Returns the minute difference between local time and Greenwich Mean Time (GMT). |
getUTCDate() | Returns the day of the month (1 to 31) from the Date object at the time of the world. |
getUTCDay() | Returns the day of the week (0 to 6) from the Date object based on the world time. |
getUTCFullYear() | Returns a four-digit year from the Date object based on the world time. |
getUTCHours() | Depending on the hour (0 to 23) of the Date object is returned when the world is in. |
getUTCMilliseconds() | Returns the date object in milliseconds (0 to 999) depending on the world. |
getUTCMinutes() | The minute (0 to 59) of the Date object is returned depending on the world. |
getUTCMonth() | Returns the month (0 to 11) from the Date object based on the world time. |
getUTCSeconds() | The second (0 to 59) of the Date object is returned depending on the world. |
getYear() | Abandoned. Use the getFullYear() method instead. |
parse() | Returns the number of milliseconds from midnight on January 1, 1970 to the specified date (string). |
setDate() | Set the day of the month in the Date object (1 to 31). |
setFullYear() | Sets the year (four digits) in the Date object. |
setHours() | Set the hours in the Date object (0 to 23). |
setMilliseconds() | Set the milliseconds (0 to 999) in the Date object. |
setMinutes() | Set the minutes in the Date object (0 to 59). |
setMonth() | Set the month in the Date object (0 to 11). |
setSeconds() | Set the seconds in the Date object (0 to 59). |
setTime() | The setTime() method sets the Date object in milliseconds. |
setUTCDate() | Set the day of the month in the Date object (1 to 31) based on the world time. |
setUTCFullYear() | Set the year (four digits) in the Date object based on the world time. |
setUTCHours() | Set the hours in the Date object (0 to 23) depending on the world time. |
setUTCMilliseconds() | Set the milliseconds (0 to 999) in the Date object based on world time. |
setUTCMinutes() | Set the minutes in the Date object (0 to 59) depending on the world time. |
setUTCMonth() | Set the month (0 to 11) in the Date object based on the world time. |
setUTCSeconds() | The setUTCSeconds() method is used to set the second field for a specified time based on World Time (UTC). |
setYear() | Abandoned. Use the setFullYear() method instead. |
toDateString() | Converts the date portion of the Date object to a string. |
toGMTString() | Abandoned. Use the toUTCString() method instead. |
toISOString() | The date format of the string returned using the ISO standard. |
toJSON() | Returns the date string in JSON data format. |
toLocaleDateString() | Convert the date portion of the Date object to a string based on the local time format. |
toLocaleTimeString() | Convert the time portion of the Date object to a string based on the local time format. |
toLocaleString() | According to the local time format, the Date object is converted to a string. |
toString() | Convert the Date object to a string. |
toTimeString() | Converts the time portion of the Date object to a string. |
toUTCString() | Depending on the world, the Date object is converted to a string. |
UTC() | Returns the number of milliseconds from January 1, 1970 to the specified date, depending on the world time. |
valueOf() | Returns the original value of the Date object. |