JavaScript Date Date Properties and Methods

JavaScript date (Date)

Date target dates and times for processing. Creation date using object new Date (). There are four ways to instantiate date:

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);

JavaScript date tutorials .

Date Properties

Attributes description
constructor Return create a Date object prototype function
prototype It allows you to add properties and methods to an object

Date Methods

method 描述
getDate() Returns the day of the month (1-31)
getDay() Returns the day of the week (from 0-6)
getFullYear() Returns the year
getHours() Returns the hour (from 0 to 23)
getMilliseconds() Returns the number of milliseconds (from 0 to 1999)
getMinutes() Back minutes (from 0 to 59)
getMonth() Returns the month (from 0-11)
getSeconds() Returns the number of seconds (from 0 to 59)
getTime() It returns the number of milliseconds since January 1, 1970 and midnight on the date specified
getTimezoneOffset() Returns the difference between the UTC time and local time, in minutes
getUTCDate() (1-31) returns the day of the month according to universal time
getUTCDay() (0-6) returns the day of the week according to the World Time
getUTCFullYear() Returns the year according to the World Time
getUTCHours() According to the World time (from 0-23) hours
getUTCMilliseconds() The milliseconds according to universal time (from 0-999)
getUTCMinutes() According to the World time (from 0-59) minutes
getUTCMonth() (0-11) Returns the month according to universal time
getUTCSeconds() The universal time to return the number of seconds (from 0 to 59)
getYear () Obsolete. Use the getFullYear () method
now() It returns the number of milliseconds since January 1970 midnight on the 1st of
parse() Parse the date string and returns the number of milliseconds since January 1, 1970 of
setDate() Target date to set the date of the month
setFullYear () Year Set Date object
setHours () Set Date object hour
setMilliseconds() Set the date object milliseconds
setMinutes() Set Date object Minutes
setMonth() Month target date set
setSeconds() Set the number of seconds the target date
setTime() Set the date specified number of milliseconds after / before January 1, 1970
setUTCDate() The universal time date object set day of the month
setUTCFullYear() According to the year Universal Time Set Date object
setUTCHours() The object set the date universal time hours
setUTCMilliseconds() The number of milliseconds to set the date in universal time object
setUTCMinutes() Universal time based on the number of minutes set date object
setUTCMonth() According to Universal Time Set Date object month
setUTCSeconds() The object set the date universal time seconds
setYear () Obsolete. Use the setFullYear () method
toDateString() Date Date object portion into a readable string
toGMTString() Obsolete. Use the toUTCString () method
toISOString() ISO standard using a string return date
toJSON () Returns a string date, date format JSON
toLocaleDateString() Use locale conventions Date object as a string date portion
toLocaleTimeString() The conventions used locale time portion of the Date object as a string
toLocaleString() Use locale conventions convert Date object to a string
toString() Date object to convert a string
toTimeString() The time portion Date object to a string
toUTCString() The universal time convert Date object to a string
UTC() According to UTC time, date returns the number of milliseconds since January 1970 midnight on the 1st of
valueOf() Date object's original value

Guess you like

Origin blog.51cto.com/13578973/2425076
Recommended