2012-05-08 3 views
0

jquery 카운트 다운을 사용하여 서버와 동기화하므로 모든 방문자가 동일한 시간을 보입니다. HTML을 호스팅하는 정적 설정을 사용하여 AppEngine에서 파일을 호스팅하고 있습니다. AppEngine에서는 PHP가 작동하지 않습니다.JQuery 카운트 다운 + 서버와 AppEngine 동기화

AppEngine의 정적 설정에서 Python을 사용하여 서버 시간과 동기화 할 수 있습니까? 내가 어떻게 datetime.now() Jquery에서 사용할 것이라고?

function countdown() { 
    var eventTime = new Date('May 23, 2012 08:00:00'); 
    $('#time-left').countdown({ until: eventTime, layout: '<ul class="timer"><li class="days">{dn}</li> <li class="hours">{hnn}</li><li class="mins">{mnn}</li><li class="secs">{snn}</li></ul>', 
           serverSync: function() { return new Date('datetime.now()') }}); 
} 

도움 주셔서 감사합니다.

답변

0

그 후 deff 현지 시각

를 년 초를 비교의 다른 시간대에 차이가 있기 때문에 .... 클라이언트 측에서 시간을 산출하므로 UTC에서 서버 시간을받는 오프셋 UTC에서 로컬 시간 변수를 생성하기 어려운
// return string must be in UTC time yyyy/MM/dd H:mm:ss format in Json result 
$.get("timerequestmethod", function (data) { 
       var dateArray = data.split(' '); 
       var seconds = getSeconds(dateArray); 

       // create countdown until 'seconds' declare in above statement 
      }); 

getSeconds = (function (dateArray) { 
     var dt = dateArray[0].split('/'); 
     var tm = dateArray[1].split(':'); 
     var times = new Date(); 
     times.setUTCFullYear(dt[0], (dt[1] > 0 ? dt[1] - 1 : dt[1]), dt[2]); 
     times.setUTCHours(tm[0]); 
     times.setUTCMinutes(tm[1]); 
     times.setUTCSeconds(tm[2]); 
     return (times - new Date())/1000; 
    }); 
관련 문제