越简单越好!

用JavaScript脚本将当地时间转换成其它时区

发表于 2007-11-01 09:06 | 1142次阅读 0次点赞   JavaScript

<script language="JavaScript">
function calcTime(city, offset) {
d = new Date();

utc = d.getTime() + (d.getTimezoneOffset() * 60000);

nd = new Date(utc + (3600000*offset));

return "The local time in " + city + " is " + nd.toLocaleString();
}


alert(calcTime('北京', '+8'));

</script>

返回顶部 ^