JS obtain the current time of day next

(Picture from W3school)

= myDate the let new new a Date (); 
myDate.setDate (myDate.getDate () +. 1 ); 
the let year = myDate.getFullYear (); // the getYear () method can be acquired but is not compatible with some browsers, so use the getFullYear ( ) the method of 
the let month the myDate.getMonth = () +. 1;    // Get the value 0-11 for the month to be + 1'd 
the let Day = myDate.getDay (); 
the let hour = myDate.getHours (); 
the let minute = myDate.getMinutes (); 
the let SECOND = myDate.getSeconds ();
 IF (month The <10 ) { 
    month The = "0" + month The; 
} 

IF (Day <10 ) { 
    Day= "0" + day;
}

if (hour < 10) {
    hour = "0" + hour;
}

if (minute < 10) {
    minute = "0" + minute;
}

if (second < 10) {
    second = "0" + second;
}

let nowTime = `${year}-${month}-${day} ${hour}:${minute}:${second}`;

 

Guess you like

Origin www.cnblogs.com/yamiya/p/12315385.html