如何让这个倒计时与每个人的时区相同? http://jsfiddle.net/3LnFm/
我需要UTC时区
这是JS -
var end = new Date('27 Dec 2013 15:29:00'); // set expiry date and time..
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour *24
var timer;
function showRemaining()
{
var now = new Date();
var distance = end - now;
if (distance < 0 ) {
clearInterval( timer );
return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor( (distance % _day ) / _hour );
var minutes = Math.floor( (distance % _hour) / _minute );
var seconds = Math.floor( (distance % _minute) / _second );
document.getElementById('countdown').innerHTML = 'Days: ' + days + '<br />';
document.getElementById('countdown').innerHTML += 'Hours: ' + hours+ '<br />';
document.getElementById('countdown').innerHTML += 'Minutes: ' + minutes+ '<br />';
document.getElementById('countdown').innerHTML += 'Seconds: ' + seconds+ '<br />';
}
timer = setInterval(showRemaining, 1000);
答案 0 :(得分:0)
使用date_default_timezone_set("UTC");