일

서버시간 알아내기

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

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 조회 412
16-02-03 조회 664
16-02-03 조회 618
16-02-02 조회 586
16-02-01 조회 549
16-02-01 조회 556
16-01-31 조회 509
16-01-31 조회 550
16-01-31 조회 523
16-01-30 조회 469
16-01-29 조회 521
16-01-29 조회 442
16-01-29 조회 449
16-01-28 조회 435
16-01-28 조회 403
16-01-27 조회 441
16-01-27 조회 471
16-01-26 조회 437
16-01-25 조회 493
16-01-25 조회 436
16-01-24 조회 396
16-01-24 조회 443
16-01-24 조회 370
16-01-23 조회 442
16-01-23 조회 467