서버시간 알아내기

· 9년 전 · 160

var xmlHttp;
function srvTime(){
    if (window.XMLHttpRequest) {//분기하지 않으면 IE에서만 작동된다.
        xmlHttp = new XMLHttpRequest(); // IE 7.0 이상, 크롬, 파이어폭스 등
        xmlHttp.open('HEAD',window.location.href.toString(),false);
        xmlHttp.setRequestHeader("Content-Type", "text/html");
        xmlHttp.send('');
        return xmlHttp.getResponseHeader("Date");
    }else if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
        xmlHttp.open('HEAD',window.location.href.toString(),false);
        xmlHttp.setRequestHeader("Content-Type", "text/html");
        xmlHttp.send('');
        return xmlHttp.getResponseHeader("Date");
    }
}
var st = srvTime();
var today = new Date(st); 

|
댓글을 작성하시려면 로그인이 필요합니다.

팁게시판

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
9년 전 조회 176
9년 전 조회 161
9년 전 조회 181
9년 전 조회 245
9년 전 조회 200
9년 전 조회 348
9년 전 조회 250
9년 전 조회 280
9년 전 조회 254
9년 전 조회 215
9년 전 조회 233
9년 전 조회 344
9년 전 조회 242
9년 전 조회 264
9년 전 조회 371
9년 전 조회 309
9년 전 조회 244
9년 전 조회 286
9년 전 조회 223
9년 전 조회 228
9년 전 조회 269
9년 전 조회 231
9년 전 조회 270
9년 전 조회 253
10년 전 조회 609