JS get current date and time

Source: Internet
Author: User
  1. Mydate. getyear (); // obtain the current year (2 digits)
  2. Mydate. getfullyear ();// Obtain the complete year (4-digit, 1970 -????)
  3. Mydate. getmonth ();// Obtain the current month (0-11, 0 represents January)
  4. Mydate. getdate ();// Obtain the current day (1-31)
  5. Mydate. getday ();// Obtain X of the current week (0-6, 0 indicates Sunday)
  6. Mydate. gettime ();// Obtain the current time (in milliseconds starting from 1970.1.1). For example, if the date is 2009.11.15, 1258272037802 is returned.
  7. Mydate. gethours ();// Obtain the current hour (0-23)
  8. Mydate. getminutes ();// Obtain the current number of minutes (0-59)
  9. Mydate. getseconds ();// Obtain the current number of seconds (0-59)
  10. Mydate. getmilliseconds ();// Obtain the current number of milliseconds (0-999)
  11. Mydate. tolocaledatestring ();// Obtain the current date
  12. VaR mytime = mydate. tolocaletimestring (); // obtain the current time
  13. Mydate. tolocalestring ();// Obtain the date and time

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.