// Js common time and date functions
Function load (){
Var time = new Date (); // Obtain the current time
Var year = time. getFullYear (); // Obtain the year
Var month = (time. getMonth () + 1); // Obtain the month 0-11
If (month <10 ){
Month = '0' + month;
}
Var ri = time. getDate (); // Obtain date 1-31
If (ri <10 ){
Ri = '0' + ri;
}
Var hour = time. getHours (); // Get hour 0-23
Var minute = time. getMinutes (); // Get minute 0-59
If (minute <10 ){
Minute = "0" + minute;
}
Var second = time. getSeconds (); // Get seconds 0-59
If (second <10 ){
Second = "0" + second;
}
// Var hm = time. getMilliseconds (); get millisecond 0-999
Var day = time. getDay (); // Obtain the week 0-6
Document. getElementById ("now_time"). style. color = '#2A7EB7'; // changed the color.
Switch (day ){
Case 0:
Day = "Sunday ";
If (day = "Sunday "){
Document. getElementById ("now_time"). style. color = '# f00'; // changed the color.
}
Break;
Case 1:
Day = "Monday ";
Break;
Case 2:
Day = "Tuesday ";
Break;
Case 3:
Day = "Wednesday ";
Break;
Case 4:
Day = "Thursday ";
Break;
Case 5:
Day = "Friday ";
Break;
Case 6:
Day = "Saturday ";
If (day = "Saturday "){
Document. getElementById ("now_time"). style. color = '# f00'; // change the color attribute in the style.
}
Break;
}
Time = year + "year" + month + "month" + ri + "day" + hour + ":" + minute + ":" + second + "" + day;
Document. getElementById ("now_time"). innerHTML = time;
// Var time = setTimeout ("load ()", 1000); // setTimeout () small setInterval () big view CUP usage
}
Var time = setInterval ("load ()", 1000 );