我正在創建必須顯示的頁面,UTC時間,我的當前時間和其他/國家/時區時間。我使用moment.min.js,moment-timezone.js,jquery.min.js - 我用 - http://www.digitoffee.com/programming/get-local-time-utc-using-moment-js/94/。請幫助我獲得另一個時區的時間。 - 這裏是的jsfiddle代碼 - https://jsfiddle.net/shejus/g63d2onw/10/ - 請幫助顯示另一個時區的時間
<html>
<head>
<title>DISPLAY TIME</title>
</head>
<body>
UTC
<br/>
<div id="divUTC"></div>
<br/>
Your Local Time with respect to above UTC time
<br/>
<div id="divLocal"></div>
<br/>
OTHER TIMEZONE TIME
<br/>
<div id="anyutctime"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/moment.min.js"></script>
<script>
$(function(){
setInterval(function(){
var divUtc = $('#divUTC');
var divLocal = $('#divLocal');
var anyutctime = $ ('#anyutctime');
//put UTC time into divUTC
divUtc.text(moment.utc().format('YYYY-MM-DD HH:mm:ss'));
//get text from divUTC and conver to local timezone
var localTime = moment.utc(divUtc.text()).toDate();
localTime = moment(localTime).format('YYYY-MM-DD HH:mm:ss');
divLocal.text(localTime);
},1000);
//Display time of Another timezone
var anyTime = moment.utc(divUtc.text()).toDate();
anyTime = moment.tz("America/Chicago").format('YYYY-MM-DD HH:mm:ss');
anyutctime.text(anyTime);
});
</script>
<script src="js/moment-timezone.js"></script>
</body>
</html>
謝謝主席先生:)你幫我這個......上帝保佑你 –