JS Date related function summary sharing _javascript skills

Source: Internet
Author: User

Copy Code code as follows:

var dateto=new Date ("8:00 1/4/2014");

Gets the time object for the specified date, or the current time if it is empty.
Copy Code code as follows:

var date=dateto.gettime ()

Gets the number of milliseconds, starting and ending times at the time of 1970 years
Copy Code code as follows:

var y=date.getfullyear ();

Get year
Copy Code code as follows:

var mm=date.getmonth () +1;

Get month
Copy Code code as follows:

var d=date.getdate ();

Get Date
Copy Code code as follows:

var h=date.gethours ();

Get hours
Copy Code code as follows:

var m=date.getminutes ();

Get the number of minutes
Copy Code code as follows:

var s=date.getseconds ();

Get number of seconds


The countdown to the idea is to calculate the two time difference, and then use

SetInterval (); The corresponding function can be executed once per second

This procedure may also use the following functions:

parseint ($trNum);

This function converts a number of string types to a numeric type.

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.