Java Script Dates Object Date ()

Source: Internet
Author: User

Java Script Dates Object Date ()

1. Get the current time

var time = new Date ()

document.write (time);

Note: Returns the time of January 1, 1970 to a specified number of milliseconds if date () has parameters

When the parameter is N,q,w N represents the year Q for the month Q represents the day where the actual month will be more than the parameter month +1

2.date.now () gets the current timestamp

document.write (Date.now ()) Gets the number of milliseconds in the current time distance from January 1, 1970

var a = new Date ()

document.write (A.gettime ()); As a result

 Note: document.write (time); Gets the current time Date.now () gets the current time distance of the number of milliseconds from January 1, 1970

3.date.parse () returns the number of milliseconds from January 1, 1970 to a specified time date

Console.log (Date.parse (2015,09,26,12,23,34));

Parameters: DATE.UTC () international designated date time to January 1, 1970.

4. Get the current month and day when you store it separately

    Console.log (D.getfullyear ());
Console.log (D.getmonth () +1);//Get month
Console.log (D.getdate ()); Get Current day
Console.log (D.getday ());//day of the week (0 is Sunday)
Console.log (D.gethours ());
Console.log (D.getminutes ());
Console.log (D.getseconds ());
Console.log (D.getmilliseconds ());
Console.log (D.gettime ());

Java Script Dates Object Date ()

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.