서버시간 알아내기

· 9년 전 · 165

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년 전 조회 189
9년 전 조회 166
9년 전 조회 193
9년 전 조회 260
9년 전 조회 215
9년 전 조회 359
9년 전 조회 263
9년 전 조회 299
9년 전 조회 268
9년 전 조회 228
9년 전 조회 248
9년 전 조회 357
10년 전 조회 255
10년 전 조회 276
10년 전 조회 386
10년 전 조회 321
10년 전 조회 253
10년 전 조회 303
10년 전 조회 239
10년 전 조회 241
10년 전 조회 286
10년 전 조회 245
10년 전 조회 283
10년 전 조회 269
10년 전 조회 627