The example in this article describes how JS dynamically loads the current time. Share to everyone for your reference. The implementation method is as follows:
<body bgcolor= "#fef4d9" onload = "time ()" > <script language= ' JavaScript ' > Function time () {var now = n
EW Date ();
var yr = Now.getyear ();
var mname = now.getmonth () + 1;
var dname = Now.getday () + 1; var Daynr = ((Now.getdate () <10)?
"0": "") + now.getdate (); var ampm = (now.gethours () >= 12)?
"PM": "AM" var hours = now.gethours ();
Hours = ((Hours >) hours-12:hours); var minutes = ((Now.getminutes () < 10)?
": 0": ":") + now.getminutes (); var seconds = ((Now.getseconds () < 10)?
": 0": ":") + now.getseconds ();
if (dname==1) day = "Sunday";
if (dname==2) day = "Monday";
if (dname==3) day = "Tuesday";
if (dname==4) day = "Wednesday";
if (dname==5) day = "Thursday";
if (dname==6) day = "Friday";
if (dname==7) day = "Saturday";
if (mname==1) month= "January";
if (mname==2) month= "February";
if (mname==3) month= "March";
if (mname==4) month= "April";
if (mname==5) month= "May";
if (mname==6) month= "June";
if (mname==7) month= "July";
if (mname==8) month= "August"; If(mname==9)
Month= "September";
if (mname==10) month= "October";
if (mname==11) month= "November";
if (mname==12) month= "December";
var daydatetime= (yr+ "year" + "" + month+ daynr+ "Day" + day+ "" + hours+ minutes+ seconds+ "" + ampm);
document.getElementById ("Face"). Innertext=daydatetime;
Timerid = settimeout ("Time ()", 1000); } </script> <form id = "form" > <div> <asp:label id = "face" runat = "server" ></ASP:LABEL&G
T
</div> </form> </body>
The
wants this article to help you with your JavaScript programming.