<strong>JS は現在の日付を表示します<br><br></strong><div class="codetitle"> <span><a style="CURSOR: pointer" data="75422" class="copybut" id="copybut75422" onclick="doCopy('code75422')"><u>コードをコピーします</u></a></span> コードは次のとおりです:</div> <div class="codebody" id="code75422"> <br><script language="Javascript"> <br>var datelocalweek=new Array("日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"); <br>var datelocalnow=new Date(); <br>var datelocalyear=datelocalnow.getFullyear(); <br>var datelocalmonth=(datelocalmonth="0" (datelocalnow.getMonth() 1)).substr( datelocalmonth.length -2,2); <br>var datelocalday=(datelocalday="0" datelocalnow.getDate()).substr(datelocalday.length-2,2); ()] ; <br>document.write(datelocalyear "year" datelocalmonth "month" datelocalday "day" " " datelocalweekday); <br><br><br> </div> <br><br><br>対応する JS は次のとおりです: <img src="http://files.jb51.net/upload/2010-3/20100324183437632.gif" border="0" alt="現在の日付と時刻を表示するJSコード_日時" ><br><br><div class="codetitle"><span>コードをコピー<a style="max-width:90%" data="67136" class="copybut" id="copybut67136" onclick="doCopy('code67136')"><u></u> コードは次のとおりです。以下:</a><div class="codebody" id="code67136"> <br>//创建一个数组,用于存放每个月的天数 <br>function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) { <br>this[0] = m0; <br>this[1] = m1; <br>this[2] = m2; <br>this[3] = m3; <br>this[4] = m4; <br>this[5] = m5; <br>this[6] = m6; <br>this[7] = m7; <br>this[8] = m8; <br>this[9] = m9; <br>this[10] = m10; <br>this[11] = m11; <br>} <br>//实现月历 <br>function calendar() { <br>var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec"; <br>var today = new Date(); <br>var thisDay; <br>var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); <br>year = today.getYear() +1900; <br>thisDay = today.getDate(); <br>if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) <br>monthDays[1] = 29; <br>nDays = monthDays[today.getMonth()]; <br>firstDay = today; <br>firstDay.setDate(1); <br>testMe = firstDay.getDate(); <br>if (testMe == 2) <br>firstDay.setDate(0); <br>startDay = firstDay.getDay(); <br>var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); <br>var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); <br>var now = new Date(); <br>document.write("<div id='rili' style='position:absolute;width:140px;left:200px;top:50px;'>") <br>document.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>") <br>document.write("<TR>"); <br>document.write(" <TD> "); <br>document.write(" <table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>"); <br>document.write(" <TR><th colspan='7' bgcolor='#C8E3FF'>"); <br>document.writeln(" <FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "年" + monthNames[now.getMonth()] + " " + now.getDate() + "日 " + dayNames[now.getDay()] + "</FONT>"); <br>document.writeln(" </TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>日</FONT></TH>"); <br>document.writeln(" <th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>一</FONT></TH>"); <br>document.writeln(" <TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>二</FONT></TH>"); <br>document.writeln(" <TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>三</FONT></TH>"); <br>document.writeln(" <TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>四</FONT></TH>"); <br>document.writeln(" <TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>五</FONT></TH>"); <br>document.writeln(" <TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>六</FONT></TH>"); <br>document.writeln(" </TR><TR>"); <br>column = 0; <br>for (i=0; i<startDay; i++) { <br>document.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>"); <br>column++; <br>} <br><br>for (i=1; i<=nDays; i++) { <br>if (i == thisDay) { <br>document.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>") <br>} <br>else { <br>document.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>"); <br>} <br>document.writeln(i); <br>if (i == thisDay) <br>document.writeln("</FONT></TD>") <br>column++; <br>if (column == 7) { <br>document.writeln("<TR>"); <br>column = 0; <br>} <br>} <br>document.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>") <br>document.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>") <br>document.writeln("现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>") <br>document.writeln("</TD></TR></TABLE></div>"); <br>} <br><br>var timerID = null; <br>var timerRunning = false; <br><br>function stopclock (){ <br>if(timerRunning) <br>clearTimeout( timerID); <br>timerRunning = false; <br>} <br><br>//Show the current time<br>function showtime () { <br>var now = new Date(); <br>var hours = now.getHours(); <br>var minutes = now.getMinutes(); <br>var seconds = now.getSeconds() <br>var timeValue = " " ((hours >12) ? hours -12 :hours ) <br>timeValue = ((minutes < 10) ? ":0" : ":") minutes <BR>timeValue = ((seconds < 10) ? ":0" : ":") seconds <BR> timeValue = (hours >= 12) ? "PM" : "AM" <br>document.clock.face.value = timeValue; <br>timerID = setTimeout("showtime()",1000);//Set timeout , make the time dynamically displayed <br>timerRunning = true; <br>} <br><br>function startclock () { <br>stopclock(); <br>showtime(); <br>} <br> </div> <br>The usage page is displayed as follows: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="45110" class="copybut" id="copybut45110" onclick="doCopy('code45110')"><u>Copy code </u></a></span> The code is as follows: </div> <div class="codebody" id="code45110"> <br><html> ; <BR><script language="JavaScript" type="text/javascript" src="time.js"> </script> <br><body bgcolor="#FFFFFF" onLoad="startclock( ); timerONE=window.setTimeout" text="#000000"> <br><script language="JavaScript" type="text/javascript"> <br>calendar(); <br></script> ; <BR></body> <br></html> <br> </div> <br>That’s OK!</span></div>