This article describes the page real-time display of the current time of a simple example, the need for friends can refer to the need
copy code code as follows:
<title>javascript Implementation page Live display current time </title>
& lt;body>
<script language= "javascript" >
function Showtime ()
{
var today,hour,second,minute,y Ear,month,date;
Var strdate;
Today=new Date ();
var n_day = Today.getday ();
Switch (n_day)
{
Case 0:{
strdate = "Sunday"
}break;
Case 1:{
strdate = "Monday"
}break;
Case 2:{
strdate = "Tuesday"
}break;
Case 3:{
strdate = "Wednesday"
}break;
Case 4:{
strdate = "Thursday"
}break;
Case 5:{
strdate = "Friday"
}break;
Case 6:{
strdate = "Saturday"
}break;
Case 7:{
strdate = "Sunday"
}break;
}
Year = Today.getyear ();
Month = Today.getmonth () +1;
Date = Today.getdate ();
Hour = today.gethours ();
minute =today.getminutes ();
Second = Today.getseconds ();
if (month<10) month= "0" +month;
if (date<10) date=0 "+date;
if (hour<10) hour= "0" +hour;
if (minute<10) minute= "0" +minute;
if (second<10) second= "0" +second;
document.getElementById (' time '). InnerHTML = years + "Year" + Month + "Month" + Date + "Day" + strdate + "" + Hour + ":" + minu Te + ":" + second; Displays the time
settimeout ("Showtime ();", 1000);//Set function Auto Execution time for 1000 ms (1 s)
}
</script>
<div id= "Times" & Gt;</div>
<script language= "JavaScript" > Showtime (); </script>
</body>