Js date related function summary sharing

  • 2020-03-26 21:24:20
  • OfStack

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

Gets the time object for the specified date, which defaults to the current time if it is empty.

var date=dateTo.getTime()

Gets the number of milliseconds, starting and ending in 1970

var y=date.getFullYear();

For years

var mm=date.getMonth()+1;

To get in

var d=date.getDate();

Get the date

var h=date.getHours();

For hours

var m=date.getMinutes();

Acquisition minutes

var s=date.getSeconds();

Get number of seconds

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

SetInterval (); Execute the corresponding function once per second

  This process may also use the following functions:

The parseInt ($trNum);

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

Related articles: