我需要访问ISTusing as3。我不需要系统时间,因为我想要精确的IST。我试过getTimezoneOffset(),但它显示了b/w IST和GMT的区别,而不管当前的系统time.In我的情况是,我严格需要来自互联网的IST,而不使用系统时间。你能帮我一下吗?非常感谢。
发布于 2013-12-12 07:12:38
这可能会帮助你得到你想要的。
<html>
<head>
<title>time test</title>
<script>
function getTime(zone, success) {
var url = 'http://json-time.appspot.com/time.json?tz=' + zone,
ud = 'json' + (+new Date());
window[ud]= function(o){
success && success(new Date(o.datetime));
};
document.getElementsByTagName('head')[0].appendChild((function(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = url + '&callback=' + ud;
return s;
})());
}
getTime('GMT', function(time){
// This is where you do whatever you want with the time:
alert(time);
document.getElementById("time").innerHTML=time;
});
</script>
</head>
<body>
<h1 id="time"></h1>
</body>
</html>
https://stackoverflow.com/questions/19848866
复制