The HTML code is as follows:
Copy Code code as follows:
<div id= "ShowTime" ></div>
The JavaScript code is as follows: The time display format is: 2011-04-04 Tuesday 12:09:34
Copy Code code as follows:
function StartTime () {
try{
var today = new Date ();
var year = Today.getfullyear ();
var month = Checknum (Today.getmonth () +1);
var date = Checknum (Today.getdate ());
var day = Today.getday ();
var hour = Checknum (Today.gethours ());
var minute = Checknum (Today.getminutes ());
var second = Checknum (Today.getseconds ());
Switch (day) {
Case 1:
Day = "one";
Break
Case 2:
Day = "Two";
Break
Case 3:
Day = "three";
Break
Case 4:
Day = "Four";
Break
Case 5:
Day = "Five";
Break
Case 6:
Day = "Six";
Break
Case 7:
Day = "th";
Break
}
var fulltime = year+ "-" +month+ "-" +date+ "" + "Week" +day+ "" +hour+ ":" +minute+ ":" +second; "
document.getElementById ("ShowTime"). InnerHTML = fulltime;
SetInterval (' StartTime () ', 1000);
}catch (e) {
alert (e.description);
}
}
function Checknum (num) {
if (num<10) {
num = "0" +num;
}
return num;
}