Javascript date object reference manual

Source: Internet
Author: User

From: http://www.w3school.com.cn/js/jsref_obj_date.asp

A good JS website,

The date object is an internal data type of JavaScript.

The date object does not have any attribute that can be read and written directly. All accesses to the date and time values are executed through the method.

Access detailed information about the date object method from the following table.

Date object Method

FF: Firefox, N: Netscape, ie: Internet Explorer

Method Description FF N IE
Date () Returns the date and time of the current day. 1 2 3
Getdate () Returns a day of a month from the date object (1 ~ 31) 1 2 3
Getday () Returns a day of the week from the date object (0 ~ 6) 1 2 3
Getmonth () Returns the month from the date object (0 ~ 11) 1 2 3
Getfullyear () Returns the year from the date object with four digits 1 4 4
Getyear () Returns the year from the date object with two or four digits. 1 2 3
Gethours () Returns the hour of the date object (0 ~ 23) 1 2 3
Getminutes () Returns the minute of the date object (0 ~ 59) 1 2 3
Getseconds () Returns the number of seconds of the date object (0 ~ 59 )) 1 2 3
Getmilliseconds () Returns the millisecond of the date object (0 ~ 999) 1 4 4
Gettime () Returns the number of milliseconds since January 1, January 1, 1970. 1 2 3
Gettimezoneoffset () Returns the minute difference (GMT) between the local time and Greenwich Mean Time) 1 2 3
Getutcdate () Returns the Day (1 ~ 31) 1 4 4
Getutcday () Returns the day of the week (0 ~ 6) 1 4 4
Getutcmonth () Returns the month (0 ~ 11) 1 4 4
Getutcfullyear () Returns the four-digit year from the date object based on the universal time. 1 4 4
Getutchours () Returns the hour of the date object based on the Universal Time (0 ~ 23) 1 4 4
Getutcminutes () Returns the minute of the date object based on the Universal Time (0 ~ 59) 1 4 4
Getutcseconds () Returns the second of the date object based on the Universal Time (0 ~ 59) 1 4 4
Getutcmilliseconds () Returns the millisecond of the date object based on the Universal Time (0 ~ 999) 1 4 4
Parse () Returns the number of milliseconds from midnight, January 1, January 1, 1970 to the specified date (string ). 1 2 3
Setdate () Set a day of the month in the date object (1 ~ 31 )) 1 2 3
Setmonth () Set the month (0 ~ 11 )) 1 2 3
Setfullyear () Set the year in the date object (four digits) 1 4 4
Setyear () Set the year (two or four digits) in the date object ). 1 2 3
Sethours () Set the hour in the date object (0 ~ 23) 1 2 3
Setminutes () Set the minute in the date object (0 ~ 59) 1 2 3
Setseconds () Set the second in the date object (0 ~ 59) 1 2 3
Setmilliseconds () Set the millisecond in the date object (0 ~ 999) 1 4 4
Settime () Calculate the date and time by adding or subtracting a specified number of milliseconds to or from midnight, January 1, January 1, 1970 1 2 3
Setutcdate () Set the day of the month in the date object according to the Universal Time (1 ~ 31) 1 4 4
Setutcmonth () Set the month in the date object according to the Universal Time (0 ~ 11) 1 4 4
Setutcfullyear () Set the year (four digits) in the date object based on the universal time) 1 4 4
Setutchours () Set the hour (0 ~ 23) 1 4 4
Setutcminutes () Set the minute (0 ~ 59) 1 4 4
Setutcseconds () Set the second in the date object according to the Universal Time (0 ~ 59) 1 4 4
Setutcmilliseconds () Set the millisecond S (0 ~ 999) 1 4 4
Tosource () Source code of the object 1 4 -
Tostring () Converts a date object to a string. 1 2 4
Totimestring () Converts the time part of the date object to a string. 1 2 4
Todatestring () Converts the date part of the date object to a string. 1 2 4
Togmtstring () Converts a date object to a string based on Greenwich Mean Time. 1 2 3
Toutcstring () Converts a date object to a string based on the universal time. 1 4 4
Tolocalestring () Converts a date object to a string based on the local time format. 1 2 3
Tolocaletimestring () Converts the time part of the date object to a string based on the local time format. 1 2 3
Tolocaledatestring () Converts the date part of the date object to a string based on the local time format. 1 2 3
UTC () Obtain a date based on the universal time, and then return the number of milliseconds from midnight, January 1, January 1, 1970 to that date. 1 2 3
Valueof () Returns the original value of the date object. 1 2 4
Date Object Attributes

FF: Firefox, N: Netscape, ie: Internet Explorer

Attribute Description FF N IE
Constructor A reference to the function used to create an object 1 4 4
Prototype Allows you to add attributes and methods to objects 1 3 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.