서버시간 알아내기

· 9년 전 · 149

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년 전 조회 165
9년 전 조회 150
9년 전 조회 170
9년 전 조회 231
9년 전 조회 187
9년 전 조회 333
9년 전 조회 234
9년 전 조회 271
9년 전 조회 246
9년 전 조회 203
9년 전 조회 222
9년 전 조회 330
9년 전 조회 229
9년 전 조회 250
9년 전 조회 354
9년 전 조회 301
9년 전 조회 231
9년 전 조회 282
9년 전 조회 215
9년 전 조회 216
9년 전 조회 262
9년 전 조회 221
9년 전 조회 260
9년 전 조회 240
9년 전 조회 596