Home >Web Front-end >JS Tutorial >js operation time (year-month-day hour-minute-second day of the week)_javascript skills
var myDate = new Date();
myDate.getYear(); //Get the current year (2 digits)
myDate.getFullYear(); //Get the complete year (4 digits, 1970-??? ?)
myDate.getMonth(); //Get the current month (0-11, 0 represents January)
myDate.getDate(); //Get the current day (1-31)
myDate. getDay(); //Get the current week ); //Get the current number of hours (0-23)
myDate.getMinutes(); //Get the current number of minutes (0-59)
myDate.getSeconds(); //Get the current number of seconds (0 -59)
myDate.getMilliseconds(); //Get the current milliseconds (0-999)
myDate.toLocaleDateString(); //Get the current date
var mytime=myDate.toLocaleTimeString(); / /Get the current time
myDate.toLocaleString( ); //Get the date and time
Typical application
//This will display the latest time on the page every one minute, the display format is "Sunday, June 20, 2010 12:17:14";
js