This article mainly introduces the page real-time update time of the JS instance code, the need for friends can refer to the
Code as follows: function StartTime () { var today = new Date (); Define date Objects var yyyy = Today.getfull Year (); Via Date Object getFullYear () method returns the year var MM = Today.getmonth () + 1; Via Date Object GetMonth () method returns the year var DD = Today.getdate (); Via Date Object GetDate () method returns the year &NBSP;VA R hh = today.gethours (); Via Date Object Gethours method return hours var mm = Today.getminutes (); Getminutes by Date object return min var SS = Today.getseconds (); GE with date objectsTseconds method Return sec //If the value of minutes or hours is less than 10, the The value plus 0, for example, if the time is 3:20 P.M. 9 seconds, then show 15:20:09 &N Bsp MM = Checktime (mm); &NBSP;DD = Checktime (DD); &NBSP;MM = checktime (mm); &NBSP;SS = checktime (ss); var day; Used to Save Week (Getday () method get week number) if (Today.getday () = 0 Day = "Sunday" if (today.getday () = 1) da y = "Monday" if (today.getday () = 2) Day = "Tuesday" if (today.getday () = 3) Day = "Wednesday " if (today.getday () = 4) Day =" Thursday " if (today.getday () = 5) Day = "Friday" if (today.getday () = 6) Day = "Saturday" & nbsp document.getelementbyid (' Nowdatetimespan '). InnerHTML = yyyy + "-" + MM + " -"+ dd +" "+ hh +": "+ mm +": "+ SS + " + day; settimeout (' StartTime () ', 1000); Reload StartTime () method &NBSP in every second function checktime (i) { if (I <) { i = "0" + i; &N Bsp return i; &NBSP, Call: <strong> Current time: </STRONG&G T <font color= "White" ><span id= "Nowdatetimespan" ></span></font>