The Date object in JavaScript

Source: Internet
Author: User
Tags local time

The syntax for creating a Date object: the var mydate=new date () Date object automatically saves the current date and time to its initial value. Date () Returns the day and time. Get: Gets getdate () returns a day from the Date object for one months (1 ~ 31). GetDay () Returns the day of the week (0 ~ 6) from the Date object. GetMonth () returns the month (0 ~ 11) from the Date object. getFullYear () returns the year as a four-digit number from a Date object. GetHours () returns the hour (0 ~ 23) of the Date object. Getminutes () returns the minute (0 ~ 59) of the Date object. Getseconds () returns the number of seconds (0 ~ 59) of the Date object. Getmilliseconds () returns the milliseconds (0 ~ 999) of the Date object. GetTime () returns the number of milliseconds since January 1, 1970. getTimezoneOffset () returns the minute difference between local time and Greenwich Mean Time (GMT). getUTCDate () Returns the day of the month (1 ~ 31) from the Date object according to the world. GetUTCDay () Returns the day of the week (0 ~ 6) from the Date object according to the world. getUTCMonth () returns the month (0 ~ 11) from the Date object, depending on the world. getUTCFullYear () returns a four-digit year from a Date object according to the world. getUTCHours () returns the hour (0 ~ 23) of the Date object according to the universal. getUTCMinutes () returns the minute (0 ~ 59) of the date object according to the universal. getUTCSeconds () returns the second (0 ~ 59) of the Date object according to the universal. getUTCMilliseconds () returns the milliseconds (0 ~ 999) of a Date object based on the universal. Parse () returns the number of milliseconds from midnight January 1, 1970 to the specified date (string).    Set: Sets Setdate () to set the day of the month in the Date object (1 ~ 31).    Dateobject.setdate (Day) setmonth () sets the month (0 ~ 11) in the Date object. Dateobject.setmonth(Month,day) setFullYear () sets the year (four digits) in the Date object. Dateobject.setfullyear (Year,month,day).    Sethours () sets the hour (0 ~ 23) in the Date object. Dateobject.sethours (HOUR,MIN,SEC,MILLISEC).    Setminutes () sets the minute (0 ~ 59) in the Date object.    Dateobject.setminutes (MIN,SEC,MILLISEC) setseconds () sets the second (0 ~ 59) in the Date object. Dateobject.setseconds (SEC,MILLISEC) setmilliseconds () sets the milliseconds (0 ~ 999) in the Date object.    SetTime () Sets the Date object in milliseconds.    Dateobject.settime (MILLISEC); The number of milliseconds to set the date and time, according to the GMT time, between midnight January 1, 1970. This type of millisecond value can be passed to the Date () constructor, which can be obtained by calling the DATE.UTC () and Date.parse () methods. Representing a date in milliseconds makes it independent of the time zone. SetUTCDate () Sets the day of the month in the Date object according to the world time (1 ~ 31). setUTCMonth () sets the month (0 ~ 11) in the Date object according to the world time. setUTCFullYear () sets the year (four digits) in the Date object according to the world time. setUTCHours () sets the hour (0 ~ 23) in the Date object according to the world time. setUTCMinutes () sets the minute (0 ~ 59) in the Date object according to the world time. setUTCSeconds () sets the seconds (0 ~ 59) in the Date object according to the world time. setUTCMilliseconds () sets the milliseconds (0 ~ 999) in the Date object according to the world time. Tosource () returns the source code of the object. This method is not valid in Internet Explorer. ToString () Converts the Date object to a string. toTimeString () Converts the time portion of a Date object to a wordCharacter string. toDateString () Converts the date part of a Date object to a string. toGMTString () Please use the toutcstring () method instead. toUTCString () Converts the Date object to a string based on the universal. toLocaleString () Converts a Date object to a string based on the local time format. toLocaleTimeString () Converts the time portion of a Date object to a string, based on the local time format. toLocaleDateString () Converts the date part of a Date object to a string, based on the local time format. UTC () returns the number of milliseconds from January 1, 1970 to the specified date, depending on the time. ValueOf () returns the original value of the Date object.

  

The Date object in JavaScript

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.