서버시간 알아내기

· 9년 전 · 1177

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,042
9년 전 조회 1,045
9년 전 조회 1,022
9년 전 조회 2,214
9년 전 조회 1,441
9년 전 조회 1,307
9년 전 조회 1,096
9년 전 조회 1,203
9년 전 조회 1,342
9년 전 조회 1,292
9년 전 조회 1,118
9년 전 조회 1,401
9년 전 조회 1,832
9년 전 조회 1,867
9년 전 조회 1,178
9년 전 조회 1,217
9년 전 조회 1,574
10년 전 조회 1,992
10년 전 조회 1,245
10년 전 조회 1,727
10년 전 조회 1,150
10년 전 조회 1,875
10년 전 조회 1,553
10년 전 조회 1,379
10년 전 조회 1,773
9년 전 조회 1,301
9년 전 조회 1,141
9년 전 조회 1,190
9년 전 조회 1,292
9년 전 조회 1,027