我正在尝试让时间 GMT + 1 显示在我的网站上。
我发现并修改了一些运行良好的代码,但现在它似乎不起作用。
有什么想法或者你知道更好的方法吗?
谢谢
<script type="text/javascript">
function display_c(){
var refresh=1000; // Refresh rate in milli seconds
mytime=setTimeout('display_ct()',refresh)
}
tday=new Array("Sun","Mon","Tues","Wed","Thurs","Fri","Sat");
tmonth=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function display_ct() {
var strcount
var d1= new Date();
var x = new Date()
x.setHours(x.getHours() + 1);
var nday2=x.getDay();
var nmonth2=x.getMonth();
var ndate2=x.getDate();
var nyear2=x.getFullYear();
var nsec2=x.getSeconds();
var nhour2=x.getHours();
var nmin=d1.getMinutes();
if(nmin<=9)
nmin="0"+nmin;
var x1=x.toUTCString();// changing the display to UTC string
document.getElementById('ct').innerHTML = ""+tday[nday2]+", "+ndate2+" "+tmonth[nmonth2]+", "+nyear2+" | "+nhour2+":"+nmin+":"+nsec2+" GMT +1";
tt=display_c();
}
</script>
<span id="ct"></span>
请您参考如下方法:
var a = new Date();
new Date(+a - a.getTimezoneOffset() + 3600000).toISOString().split(".")[0];