일

서버시간 알아내기

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

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

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

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
MySQL 16-07-30 조회 1.2만
node.js 16-07-29 조회 4,493
PHP 16-07-27 조회 3,627
16-07-15 조회 6,916
16-07-12 조회 3,697
16-07-04 조회 5,048
16-06-27 조회 3,541
16-06-24 조회 7,210
16-06-23 조회 4,240
16-06-23 조회 2,428
16-06-22 조회 4,040
16-06-22 조회 2,956
16-06-22 조회 2,687
16-06-21 조회 2,991
16-06-21 조회 2,702
16-06-21 조회 2,705
16-06-20 조회 3,725
16-06-20 조회 3,146
16-06-20 조회 2,544
16-06-19 조회 2,405
16-06-19 조회 2,528
16-06-19 조회 2,222
16-06-18 조회 5,251
16-06-18 조회 3,035
16-06-04 조회 2,687
16-05-26 조회 2,857
16-05-19 조회 2,749
16-05-12 조회 2,521
16-05-11 조회 2,860
16-05-11 조회 3,067