Latest web development tutorials

JavaScript Date Object

Date Object

Date object is used to handle the actual date.

Create a Date object: new Date ().

These four methods can also create a Date object:

var d = new Date();
var d = new Date( milliseconds );
var d = new Date( dateString );
var d = new Date( year , month , day , hours , minutes , seconds , milliseconds );

A more complete tutorial refer to the date of actual JavaScript Date Object tutorial .


Date Object Properties

Attributes description
constructor Returns to create this object Date function reference.
prototype It gives you the ability to add properties and methods to an object.

Date Object Methods

method description
getDate () Date object returned from a day of the month (1 to 31).
getDay () Date object returned from a day of the week (0-6).
getFullYear () Four digits from the Date object returns the year.
getHours () Date object h (0 to 23).
getMilliseconds () Date object in milliseconds (0 to 999).
getMinutes () Date object minute (0 to 59).
getMonth () Returns the month from a Date object (0 to 11).
getSeconds () Date object number of seconds (0 to 59).
getTime () It returns the number of milliseconds January 1, 1970 to the present.
getTimezoneOffset () Returns the local time and Greenwich Mean Time (GMT) minutes difference.
getUTCDate () Depending on the return of the world from the mid-Date target date (1 to 31).
getUTCDay () It returns the week from a Date object according to the World Day (0-6).
getUTCFullYear () Back in the world. According to the four-digit year from the Date object.
getUTCHours () Date object according to Universal Time h (0 to 23).
getUTCMilliseconds () Date object according to the World millisecond (0 ~ 999).
getUTCMinutes () Date object according to Universal Time minutes (0 to 59).
getUTCMonth () According to the World March when returning from a Date object (0 to 11).
getUTCSeconds () Date object according to Universal Time seconds (0 to 59).
getYear () Obsolete. Use getFullYear () method in place.
parse () Returns January 1, 1970 to midnight on the specified date (string) is the number of milliseconds.
setDate () Setting Date object day of the month (1 to 31).
setFullYear () Date object in the year (four digits).
setHours () Setting Date object h (0 to 23).
setMilliseconds () Date object in milliseconds (0 to 999).
setMinutes () Date object in minutes (0 to 59).
setMonth () Date object in the month (0 to 11).
setSeconds () Date object in seconds (0 to 59).
setTime () setTime () method of Date object in milliseconds.
setUTCDate () When setting up the world according to one day (1 ~ 31) Date object month.
setUTCFullYear () Date object in the year (four digits) According to the World.
setUTCHours () Setting Date object h (0 to 23) According to the World.
setUTCMilliseconds () Date object in milliseconds (0 to 999) according to the world.
setUTCMinutes () Date object in minutes (0 to 59) According to the World.
setUTCMonth () Date object in the month (0 to 11) According to the World.
setUTCSeconds () setUTCSeconds () method is used according to Universal Time (UTC) setting specifies the time in seconds field.
setYear () Obsolete. Use setFullYear () method in place.
toDateString () The date portion of a Date object to a string.
toGMTString () Obsolete. Use toUTCString () method in place.
toISOString () Returns a string using the ISO standard date format.
toJSON () In return JSON data format date string.
toLocaleDateString () According to local time format, the date part of the Date object to a string.
toLocaleTimeString () According to the local time, the time part of the Date object to a string.
toLocaleString () According to the local time, the Date object to a string.
toString () The Date object to a string.
toTimeString () The time portion of the Date object to a string.
toUTCString () According to the World when the Date object to a string.
UTC () It returns the number of milliseconds January 1, 1970 to the date specified in the world according to.
valueOf () Returns the original value of the Date object.