일

서버시간 알아내기

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

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

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

토크

3,606건

오픈소스 관련 다양한 이야기를 자유롭게 나눠요

+
제목 글쓴이 날짜 조회
16-05-16 조회 2,324
16-05-15 조회 1,545
16-05-12 조회 1,395
16-05-11 조회 1,194
16-05-11 조회 1,300
16-05-11 조회 1,445
16-05-04 조회 1,383
16-05-01 조회 1,215
16-04-28 조회 1,493
16-04-27 조회 1,938
16-04-01 조회 1,965
16-04-12 조회 1,270
16-03-31 조회 1,312
16-03-29 조회 1,677
16-03-11 조회 2,113
16-03-10 조회 1,351
16-03-09 조회 1,817
16-03-09 조회 1,252
16-02-18 조회 1,967
16-02-16 조회 1,654
16-02-03 조회 1,476
16-02-02 조회 1,869
16-03-21 조회 1,392
16-03-21 조회 1,226
16-03-19 조회 1,284
16-03-19 조회 1,386
16-03-17 조회 1,128
16-03-17 조회 1,027
16-03-14 조회 1,259
16-03-13 조회 1,091