The getYear() function was deprecated a long time ago because it was displayed incorrectly in Firefox. It is recommended to use the getFullYear() function.
In addition, Firefox does not support the innerText attribute and needs to be changed to textContent to receive it.
Then attach the code
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;
//Browser version number for testing
//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;
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn