<! DOCTYPE html>functionShijian () {varToday =NewDate (); varHH =today.gethours (); varMM =today.getminutes (); varSS =today.getseconds (); varDay =Today.getday (); varDate =today.getdate (); varYear =today.getfullyear (); varmonth = Today.getmonth () + 1; /*declares a variable to receive the converted string*/ varDayday; /*use switch to complete the conversion operation*/ Switch(day) { Case1: Dayday= "One"; Break; Case2: Dayday= "Two"; Break; Case3: Dayday= "three"; Break; Case4: Dayday= "Four"; Break; Case5: Dayday= "Five"; Break; Case6: Dayday= "Six"; Break; Case7: Dayday= "Day"; Break; } /*declare am and PM to represent morning and afternoon respectively, since the time is set to 12-hour system, from the user's point of view, to provide convenience*/ varAPM = "PM"; varABM = "AM"; /*The time taken from the system is 24-hour, and we subtract 12 to convert it to 12-hour .*/ if(HH > 12) { varnum = hh-12; document.getElementById ("ABC"). InnerHTML = "Current system time:" + "<br/><br/>" + year + "years" + month + "Month" + Date + "Day" + num + "when" + mm + "min" + SS + "SEC" + " " + "Week" + Dayday + " " + " " + APM + "<br/><br/>" + "Good afternoon!" Welcome to tb128!. "; } Else{document.getElementById ("ABC"). InnerHTML = "Current system time:" + "<br/><br/>" + year + "years" + month + "Month" + Date + "Day" + hh + "When" + mm + "min" + ss + "seconds" + " " + "Week" + Dayday + " " + " " + ABM + "<br/><br/>" + "Good afternoon!" Welcome to tb128!. "; } } /*executes the Shijian () method once every 1000 milliseconds (1 seconds)*/SetInterval ("Shijian ()", 1000) </script>javascript-get local time displayed in 12-hour system