Home > Web Front-end > JS Tutorial > body text

Summary and sharing of js date related functions_javascript skills

WBOY
Release: 2016-05-16 17:20:12
Original
1261 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template