일

서버시간 알아내기

· 2016-04-12 (화) 12:46:04 · 380

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

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

팁게시판

6,077건

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

+
제목 글쓴이 날짜 조회
16-04-12 조회 374
16-04-12 조회 381
16-04-11 조회 385
16-04-07 조회 469
16-04-01 조회 451
16-03-21 조회 579
16-03-21 조회 476
16-03-19 조회 546
16-03-19 조회 490
16-03-17 조회 455
16-03-17 조회 472
16-03-14 조회 574
16-03-13 조회 475
16-03-11 조회 505
16-03-11 조회 602
16-03-09 조회 566
16-03-09 조회 467
16-03-08 조회 535
16-03-08 조회 469
16-03-08 조회 490
16-03-08 조회 540
16-03-07 조회 480
16-03-07 조회 509
16-03-07 조회 519
16-03-02 조회 854