Built-in objects in JavaScript -8-date objects-4

Source: Internet
Author: User

Learning Goals

1. Learn how to create date objects

2. Mastering The method of getting DateTime in a Date object

3. Learn How to set the date time in the Date object

How to create a Date object

syntax:new Date ();

Function: Create a DateTime object

Return value: Returns the current DateTime object, in the case of a reference.

Description: If you want to create a Date object based on a specific date and time, you must pass in a date that represents that day:

The number of milliseconds or a comma-separated set of parameters that represent the day of the month and seconds.

How to get the day, minute and week of the month

1.getFullYear (): returns a 4 -digit year

2.getMonth (): Returns the month of the date with a return value of 0-11

3.getDate (): returns the number of days in the month

4.getDay (): return week, return value is 0-6

5.getHours (): return hour

6.getMinutes (): return points

7.getSeconds (): return seconds

8.getTime (): Returns the number of milliseconds that represent the date

The method of setting the day of the month and the week

1.setFullYear (): returns a 4 -digit year

2.setMonth (): Returns the month of the date, starting at 0 ,0 for 1 months

3.setDate (): Set Date

4.4.setDay (): return week, starting from 0 ,0 for Sunday

5.setHours (): return hour

6.setMinutes (): return points

7.setSeconds (): return seconds

8.setTime (): sets the date in milliseconds and changes the entire date

Built-in objects in JavaScript -8-date objects-4

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.