可能重复:
在javascript中将日期转换为另一个时区
如何让这个节目得到台北的时间?他们有什么需要解决的吗?还是我需要为它添加一些代码?
var yudan = "";
var now = new Date();
var month = now.getMonth() + 1;
var date = now.getDate();
var year = now.getFullYear();
if (year < 2000) year = year + 1900;
document.write(year + "." + yudan + month + "." + date + ".");
document.write("<span id=\"yudan_clock\"><\/span>");
var now,hours,minutes,seconds,timeValue;
function yudan_time(){
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
timeValue = (hours >= 12) ? " " : " ";
timeValue += ((hours > 12) ? hours - 0 : hours) + ":";
timeValue += ((minutes < 10) ? " 0" : " ") + minutes + ":";
timeValue += ((seconds < 10) ? " 0" : " ") + seconds + "";
document.getElementById("yudan_clock").innerHTML = timeValue;
setTimeout(yudan_time, 100);}
yudan_time();