Date~JS

Date objects are based on the number of milliseconds since January 1, 1970 (UTC).
Calling it as a regular function (ie without the new operator) will return a string, not a date object. Also, unlike other JavaScript types, Date objects have no literal format.
If the value is larger than a reasonable range (such as 13 for the month or 70 for the minute), the adjacent value will be adjusted. For example, new Date(2013, 13, 1) is equal to new Date(2014, 1, 1), which both represent the date 2014-02-01 (note that the month starts from 0). Other values ​​are similar, new Date(2013, 2, 1, 0, 70) is equal to new Date(2013, 2, 1, 1, 10), which both represent the time 2013-03-01T01:10:00.
When Date is called as a constructor and multiple parameters are passed in, the parameters defined represent the local time.
If no parameters are entered, the Date constructor will create a Date object based on the current time set by the system.
If at least two parameters are provided, the remaining parameters will default to 1 (if no day parameter is provided) or 0.

var today = new Date();
var today = new Date(1453094034000); // by timestamp(accurate to the millimeter)
var birthday = new Date('December 17, 1995 03:24:00');
var birthday = new Date('1995-12-17T03:24:00');
var birthday = new Date(1995, 11, 17);
var birthday = new Date(1995, 11, 17, 3, 24, 0);
//new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);

Date.prototype

Allows adding properties to Date instance objects.

Date.length

The value of Date.length is 7. This is the number of arguments this constructor accepts.

Date.now()

Returns the number of milliseconds elapsed since 1970-1-1 00:00:00 UTC (Universal Time).

Date.parse()

Parses a string representing a date and returns the number of milliseconds elapsed since 1970-1-1 00:00:00.

Date.UTC()

Accepts the same arguments as the constructor's longest form (from 2 to 7) and returns the number of milliseconds elapsed since 1970-01-01 00:00:00 UTC.

Date.prototype.getDate()

Returns the day of the month (1-31) for the specified date object according to local time.

Date.prototype.getDay()

Returns the day of the week (0-6) for the specified date object according to local time.

Date.prototype.getFullYear()

Returns the year of the specified date object according to local time (four digits for a four-digit year).

Date.prototype.getHours()

Returns the hour (0-23) of the specified date object according to local time.

Date.prototype.getMilliseconds()

Returns the microseconds (0-999) for the specified date object according to local time.

Date.prototype.getMinutes()

Returns the minute (0-59) of the specified date object according to local time.

Date.prototype.getMonth()

Returns the month (0-11) of the specified date object according to local time.

Date.prototype.getSeconds()

Returns the number of seconds (0-59) for the specified date object according to local time.

Date.prototype.getTime()

Returns the number of milliseconds elapsed since 1970-1-1 00:00:00 UTC (Coordinated Universal Time) to this date, or negative for times before 1970-1-1 00:00:00 UTC.

Date.prototype.getTimezoneOffset()

Returns the time zone offset for the current time zone.

Date.prototype.getUTCDate()

Returns the day (date) of the month (1-31) in the specified date according to universal time.

Date.prototype.getUTCDay()

Returns the day of the week (0-6) in the specified date according to universal time.

Date.prototype.getUTCFullYear()

Returns the year (4 digits for 4-digit years) in the specified date according to universal time.

Date.prototype.getUTCHours()

Returns the hours (0-23) in the specified date according to universal time.

Date.prototype.getUTCMilliseconds()

Returns the milliseconds (0-999) in the specified date according to universal time.

Date.prototype.getUTCMinutes()

Returns the minutes (0-59) in the specified date according to universal time.

Date.prototype.getUTCMonth()

Returns the month (0-11) in the specified date according to universal time.

Date.prototype.getUTCSeconds()

Returns the seconds (0-59) in the specified date according to universal time.

Date.prototype.setDate()

Sets the day of the month for the specified date object according to local time.

Date.prototype.setFullYear()

Sets the full year for the specified date object according to local time (a four-digit year is four digits).

Date.prototype.setHours ()

Sets the hours for the specified date object according to local time.

Date.prototype.setMilliseconds()

Sets the number of milliseconds for the specified date object according to local time.

Date.prototype.setMinutes()

Sets the number of minutes for the specified date object according to local time.

Date.prototype.setMonth()

Sets the month for the specified date object according to local time.

Date.prototype.setSeconds()

Sets the number of seconds for the specified date object according to local time.

Date.prototype.setTime()

Sets the date object's time by specifying the number of milliseconds elapsed since 1970-1-1 00:00:00 UTC, negative values ​​can be used for times earlier than 1970-1-1 00:00:00 UTC.

Date.prototype.setUTCDate()

Sets the day of the month (1 ~ 31) in the Date object according to Universal Time.

Date.prototype.setUTCFullYear()

Sets the year (four digits) in the Date object according to Universal Time.

Date.prototype.setUTCHours()

Sets the hour in the Date object according to Universal Time (0 ~ 23).

Date.prototype.setUTCMilliseconds()

Sets the milliseconds (0 ~ 999) in the Date object according to Universal Time.

Date.prototype.setUTCMinutes()

Sets the minutes in the Date object according to Universal Time (0 ~ 59).

Date.prototype.setUTCMonth()

Sets the month (0 ~ 11) in the Date object according to Universal Time.

Date.prototype.setUTCSeconds()

Sets the seconds in the Date object according to world time (0 ~ 59).

Date.prototype.toDateString()

Returns a string of the date portion of this date object in human-readable form.

Date.prototype.toISOString()

Converts a date to a string in ISO 8601 extended format.

Date.prototype.toJSON()

Use toISOString() to return a string representing the date. For use in the JSON.stringify() method.

Date.prototype.toLocaleDateString()

Returns a string representing the date part of this date object in a format that is locality sensitive as set by the system.

Date.prototype.toLocaleString()

Returns a string representing this date object that is locality sensitive as set by the system. Overrides the Object.prototype.toLocaleString() method.

Date.prototype.toLocaleTimeString()

Returns a string representing the time portion of this date object in a format that is locality sensitive as set by the system.

Date.prototype.toString()

Returns a string representing this date object. Overrides the Object.prototype.toString() method.

Date.prototype.toTimeString()

Returns a string of the time portion of a date object in human-readable format.

Date.prototype.toUTCString()

Converts a date object to a string in the UTC time zone.

Date.prototype.valueOf()

Returns the raw value of a Date object. Overrides the Object.prototype.valueOf() method.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324778002&siteId=291194637