<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> </Head> <Bodyonload = "Startime ()">//The purpose of the onload here is that when the page is loaded, it executes the function startime () <DivID= "Div"style= "border:1px solid royalblue;floating:left; margin:0 auto; display:inline;"></Div> <Script> //var date=new date (); //document.write (date); //document.write (Date.getfullyear ());//The year is the output //document.write (Date.getday ());//output is the specific day of the week //document.write (Date.gettime ());//The output is a timestamp //date.setfullyear (2011,2,3);//Set the time yourself //document.write (date); functionStartime () {varT=NewDate (); //Create a Date object to reference the related date varh=t.gethours (); varm=t.getminutes (); vars=t.getseconds (); document.getElementById ("Div"). InnerHTML=h+':'+m+':'+s; M=Checktime (m); S=Checktime (s); T=SetTimeout ("Startime ()", - ); //Note the use of the parameters of the function, the first parameter is to be quoted, here is the recall of the original function, the implementation of the Refresh function
The second parameter is the time of the refresh, 500 represents 0.5 seconds } functionChecktime (i) {//Here just for the sake of beauty, in front of the single digit, the display of the number + a 0 if(i<Ten) {i="0"+i; } returni; } </Script> </Body></HTML><!--[email protected] Time: 2017-03-11 Description: Timestamp definition: Time stamp refers to GMT January 01, 1970 00:00 00 seconds (Beijing time January 01, 1970 08:00 00 seconds) The total number of seconds to present. -
The time function of JS realizes a electronic table