The date of JavaScript

Source: Internet
Author: User
Tags time zones local time

1, Date.parse (): Receives a string parameter that represents a date, and then attempts to return the number of milliseconds of the corresponding date based on the string. such as "6/13/2015", "January 12,2014", "Tue May 2004 00:00:00 GMT-0700", "2004-05-25t00:00:00"

2. Get start time and stop time

var start=date.now ();

DoSomething ();

var stop=date.now ();

Result=stop-start;

3. Use + to convert a Date object to a string

var start = +new Date ();

DoSomething ();

var stop= +new Date ();

result = Stop start;

4, toLocaleString ()

5. ToString ()

6, ValueOf ()//returns the number of seconds, often used to compare

Method of date formatting

7. toDateString () displays weekday, month, day, and year in an implementation-specific format.

8. toTimeString () Displays hours, minutes, seconds, and time zones in an implementation-specific format

9. toLocaleDateString () displays weekday, month, day, and year in a locale-specific format.

10. toLocaleTimeString () Displays hours, minutes, seconds in an implementation-specific format

11. toUTCString () full UTC date in implementation-specific format

Date/Time Component method

12, GetTime () returns the number of milliseconds representing the date; same as valueof ()

13, SetTime (milliseconds) set the date in milliseconds and change the entire date

14, getFullYear () 4-digit year

15, getUTCFullYear () returns the 4-digit year of the UTC date

16, setFullYear (year) set the year of the date, must be a 4-digit number

17, setUTCFullYear (year)

18, GetMonth () returns the month of the date, where 0 represents January, 11 means December

19, getUTCMonth ()

20, Setmonth ()

21, setUTCMonth ()

22, GetDate () returns the number of days in the date month (1~31)

23, getUTCDate ()

24, SetDate (day)

25, SetUTCDate (day)

26, GetHours () (0~23)

27, getUTCHours ()

28, Sethours ()

29, setUTCHours ()

30, getminutes ()

31, getUTCMinutes ()

32, setminutes (min)

33, setUTCMinutes (min)

34, Getseconds ()

35, getUTCSeconds ()

36, Setseconds ()

37, setUTCSeconds ()

38, Getmilliseconds ()

39, getUTCMilliseconds ()

40, Setmilliseconds (MS)

41, setUTCMilliseconds ()

42, getTimezoneOffset () returns the number of minutes between local time and UTC time.

The date of JavaScript

Related Article

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.