일

서버시간 알아내기

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

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-03-02 조회 875
16-01-19 조회 504
15-12-23 조회 657
15-12-08 조회 1,304
14-10-30 조회 2,894
14-06-06 조회 2,307
12-08-30 조회 1,516
12-08-20 조회 1,286
12-07-15 조회 2,717
12-07-13 조회 1,492
12-07-06 조회 1,479
12-06-27 조회 1,031
12-06-23 조회 1,147
12-05-03 조회 3,112
12-04-20 조회 2,056
12-03-29 조회 2,377
12-03-22 조회 2,724
12-03-22 조회 1,468
12-03-21 조회 1,296
12-03-11 조회 1,635
12-03-06 조회 1,912
12-02-22 조회 2,251
12-02-17 조회 1,232
12-02-17 조회 4,280
12-02-14 조회 3,901