페이지 프론트 데스크 디스플레이
코드 사본은 다음과 같습니다.
<span id = "clock"style = "font-size : 14px;"> </span>
JS 스크립트
코드 사본은 다음과 같습니다.
$ (document) .ready (function () {
// 첫 번째 유형
showtime ();
// 두 번째 유형
var clock = 새 시계 ();
clock.display ($ ( "#clock"));
});
// 시스템의 첫 번째 처리 방법이 표시됩니다.
함수 showtime () {
var myArray = 새로운 배열 (7);
var td = 새로운 날짜 ();
MyArray [0] = "일요일";
MyArray [1] = "월요일";
MyArray [2] = "화요일";
MyArray [3] = "수요일";
MyArray [4] = "목요일";
MyArray [5] = "금요일";
MyArray [6] = "토요일";
주중 = td.getday ();
var h = td.gethours ();
var m = td.getMinutes ();
var s = td.getSeconds ();
var hstr = h;
var mstr = m;
var isr = s;
if (h <10) {hstr = "0" + h};
if (m <10) {mstr = "0" + m};
if (s <10) {isr = "0" + s};
$ ( "#clock"). InnerHtml ( '현재 시간 :' + new date (). tolocaledatestring () + " + myArray [주간] +" " + hstr +": " + mstr +": " + ISR) ;
settimeout (Showtime, 1000);
}
// 시스템의 현재 시간을 처리하는 두 번째 방법이 표시됩니다.
함수 클록 () {
var date = 새 날짜 ();
this.year = date.getlyear ();
this.month = date.getmonth ()+1;
this.date = date.getDate ();
this.day = newArray ( "일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일") [date.getDay ()];
this.hour = date.gethours () <10? "0"+date.gethours () : date.gethours ();
this.minute = date.getMinutes () <10? "0"+date.getMinutes () : date.getMinutes ();
this.second = date.getSeconds () <10? "0"+date.getSeconds () : date.getSeconds ();
this.tostring = function () {
"현재 시간은"+this.year+"year"+this.month+"month"+this.date+"day"+this.hour+":"+this.minute+":"+this.second+""+ 이 .day;
};
this.tosimpledate = function () {
return this.year+"-"+this.month+"-"+this.date;
};
this.todetaildate = function () {
return this.year+"-"+this.month+"-"+this.date+""+this.hour+":"+this.minute+":"+this.second;
};
this.display = function (ele) {
varclock = newClock ();
ele.innerhtml = clock.toString ();
Window.settimeout (function () {clock.display (ele);}, 1000);
};
}