Commonly used date methods

First var date = new Date(); // declaration

  date.getTime(); //get the number of milliseconds from 1970

  date.valueOf(); //get the number of milliseconds from 1970

 var date = new Date();   // declare 
console.log(date.getTime());   // proposed 
console.log(date.valueOf());
 // use 
console.log(Date.now( directly ));
console.log(+new Date());

 

Get date and time

getDate() Get day 1-31 
getDay () Get week 0-6       
getMonth () Get month   0-11
getFullYear () Get the full year (all browsers support it)
getHours () get hours 0-23 
getMinutes () get minutes 0-59 
getSeconds () get seconds   0-59
getMilliseconds () gets the current milliseconds
getTime() returns the cumulative milliseconds (from midnight on 1/1/1970)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325168759&siteId=291194637