js - Get the current date

var date = new Date();

DATE .getYear (); // Get the current year (2)

DATE .getFullYear (); // get the full year (4)

DATE .getMonth (); // Get the current month (0-11,0 behalf January)

DATE .getDate (); // Get the current day (1-31)

DATE .getDay (); // Get the current week X (0-6,0 for Sunday)

DATE .getTime (); // get the current time (number of milliseconds from the start 1970.1.1)

DATE .getHours (); // Get the current number of hours (0-23)

DATE .getMinutes (); // Get the current number of minutes (0-59)

DATE .getSeconds (); // Get the current number of seconds (0-59)

DATE .getMilliseconds (); // get the current number of milliseconds (0-999)

DATE .toLocaleDateString (); // Get the current date

MyTime var = DATE .toLocaleTimeString (); // get the current time

DATE .toLocaleString (); // get the date and time

Guess you like

Origin www.cnblogs.com/500m/p/11669524.html