JS Code
Copy codeThe Code is as follows:
<Script language = "javascript">
Function real‑ime (clock ){
Var now = new Date (); // create a Date object
Var year = now. getFullYear (); // obtain the year
Var month = now. getMonth (); // obtain the month
Var date = now. getDate (); // get the date
Var day = now. getDay (); // obtain the week
Var hour = now. getHours (); // get the hour
Var minu = now. getMinutes (); // get minutes
Var sec = now. getSeconds (); // get seconds
Month = month + 1;
Var arr_week = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
Var week = arr_week [day]; // week for retrieving Chinese Characters
Var time = year + "year" + month + "month" + date + "day" + week + "" + hour + ":" + minu + ":" + sec; // combine the system time
Clock. innerHTML = time; // display the system time
}
Window. onload = function (){
Window. setInterval ("realeffecime (clock)", 1000); // obtain and display the system time in real time
}
</Script>
Add id = "clock" to the display area, for example, <td id = "clock"/>