Home  >  Article  >  Web Front-end  >  Summary and sharing of js date related functions_javascript skills

Summary and sharing of js date related functions_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:20:121260browse

Copy code The code is as follows:

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

Get the time object of the specified date. If it is empty, it defaults to the current time.
Copy code The code is as follows:

var date=dateTo.getTime()

Get the number of milliseconds, starting and ending in 1970
Copy the code The code is as follows:

var y=date.getFullYear();

Get the year
Copy code The code is as follows:

var mm=date.getMonth() 1;

Get the month
Copy Code The code is as follows:

var d=date.getDate();

Get date
Copy code The code is as follows:

var h=date.getHours();

Get the hours
Copy code The code is as follows:

var m=date.getMinutes();

Get the minutes
Copy code The code is as follows:

var s= date.getSeconds();

Get seconds


The idea of ​​countdown is to calculate the time difference between two times, and then use

setInterval(); just execute the corresponding function once per second

This process may also use the following functions:

parseInt($trNum);

This function converts string type numbers into numeric types.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn