일

서버시간 알아내기

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

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에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
16-05-04 조회 4,479
16-04-28 조회 2,765
JavaScript 16-04-12 조회 4,840
PHP 16-03-21 조회 4,591
Mobile 16-03-21 조회 4,140
PHP 16-03-19 조회 4,400
웹서버 16-03-19 조회 7,957
PHP 16-03-17 조회 3,487
PHP 16-03-17 조회 4,342
PHP 16-03-14 조회 3,984
PHP 16-03-13 조회 3,954
MySQL 16-03-11 조회 4,340
PHP 16-03-09 조회 5,779
MySQL 16-03-09 조회 5,499
PHP 16-03-08 조회 3,734
PHP 16-03-08 조회 4,217
PHP 16-03-08 조회 3,827
PHP 16-03-08 조회 7,124
PHP 16-03-07 조회 3,896
웹서버 16-03-07 조회 4,428
PHP 16-03-07 조회 3,681
node.js 16-03-02 조회 8,720
PHP 16-02-29 조회 5,591
PHP 16-02-25 조회 5,425
PHP 16-02-22 조회 5,583
MySQL 16-02-18 조회 6,431
jQuery 16-02-15 조회 4,515
PHP 16-02-12 조회 4,402
PHP 16-02-04 조회 5,351
PHP 16-02-04 조회 5,491