The getYear () function is not recommended because it is incorrectly displayed in Firefox. Therefore, the getFullYear () function is recommended, next we will introduce in detail how to use the getYear function in different browsing scenarios. The getYear () function is not recommended a long time ago, because it is incorrectly displayed in Firefox, we recommend that you use the getFullYear () function.
Firefox does not support the innerText attribute. You need to change it to textContent to receive the message.
Then, attach the code
The Code is as follows:
Var s, Sys ={}, ua = window. navigator. userAgent. toLowerCase ();
(S = ua. match (/msie ([\ d.] + )/))? Sys. ie = s [1]:
(S = ua. match (/firefox \/([\ d.] + )/))? Sys. firefox = s [1]:
(S = ua. match (/chrome \/([\ d.] + )/))? Sys. chrome = s [1]:
(S = ua. match (/opera. ([\ d.] + )/))? Sys. opera = s [1]:
(S = ua. match (/version \/([\ d.] +). * safari /))? Sys. safari = s [1]: 0;
// Test the browser version.
// If (Sys. ie) {document. write ('ie: '+ Sys. IE );}
// If (Sys. firefox) {document. write ('Firefox: '+ Sys. Firefox );}
// If (Sys. chrome) {document. write ('chrome: '+ Sys. Chrome );}
// If (Sys. opera) {document. write ('Opera: '+ Sys. Opera );}
// If (Sys. safari) {document. write ('safari: '+ Sys. Safari );}
Var today = new Date ();
Var day, date;
If (today. getDay () = 0) {day = "Sunday ";}
If (today. getDay () = 1) {day = "Monday ";}
If (today. getDay () = 2) {day = "Tuesday ";}
If (today. getDay () = 3) {day = "Wednesday ";}
If (today. getDay () = 4) {day = "Thursday ";}
If (today. getDay () = 5) {day = "Friday ";}
If (today. getDay () = 6) {day = "Saturday ";}
Date = "today is:" + (today. getFullYear () + "year" + (today. getMonth () + 1) + "month" + today. getDate () + "day" + day + "";
If (Sys. firefox)
{
Document. getElementById ('time _ id'). textContent = date;
} Else {
Document. getElementById ('time _ id'). innerText = date;
}