我有一个带有javascript的时钟我希望通过javascript将此时钟更改为拉丁数字阿拉伯数字,我尝试如下代码,但它不起作用。怎么解决它?
DEMO: http://jsfiddle.net/NdzHg/
<script type="text/javascript">
var interval = self.setInterval("clock()", 1000);
function clock() {
var rep = {
'0': '۰',
'1': '۱',
'2': '۲',
'3': '۳',
'4': '۴',
'5': '۵',
'6': '۶',
'7': '۷',
'8': '۸',
'9': '۹',
}
var date = new Date();
var hourOffset = 4;
date.setUTCHours(date.getUTCHours(), date.getUTCMinutes());
var time = date.getTime();
date.setUTCFullYear(date.getUTCFullYear(), 3, 21);
var dstStart = date.getTime();
date.setUTCFullYear(date.getUTCFullYear(), 9, 22);
var dstEnd = date.getTime();
if (time > dstStart && time < dstEnd){ hourOffset = 4;}
date.setUTCHours(date.getUTCHours() + hourOffset, date.getUTCMinutes() + 30);
var output = date.getUTCHours() + ":" + date.getUTCMinutes() + ":" + date.getUTCSeconds();
for (key in rep) {
str = output.split(key).join(rep[key]);
}
$("#clock").html(str);
}
</script>
<div id="clock"></div>
答案 0 :(得分:2)
试试:http://jsfiddle.net/McxL5/顺便说一句,这是在mootools ......
以下是jquery版本:http://jsfiddle.net/McxL5/12/