서버시간 알아내기

· 9년 전 · 1197

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); 

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

토크

개발과 관련된 어떤 얘기도 괜찮습니다.

+
제목 글쓴이 날짜 조회
9년 전 조회 1,055
9년 전 조회 1,055
9년 전 조회 1,036
9년 전 조회 2,227
9년 전 조회 1,453
9년 전 조회 1,320
9년 전 조회 1,113
9년 전 조회 1,212
9년 전 조회 1,353
9년 전 조회 1,300
9년 전 조회 1,132
9년 전 조회 1,409
9년 전 조회 1,846
9년 전 조회 1,878
9년 전 조회 1,198
9년 전 조회 1,237
9년 전 조회 1,590
10년 전 조회 2,008
10년 전 조회 1,262
10년 전 조회 1,739
10년 전 조회 1,163
10년 전 조회 1,888
10년 전 조회 1,567
10년 전 조회 1,394
10년 전 조회 1,786
9년 전 조회 1,316
9년 전 조회 1,156
9년 전 조회 1,202
9년 전 조회 1,302
9년 전 조회 1,041