0

我有一个带有 javascript 的时钟我想通过 javascript 将这个时钟的拉丁数字更改为阿拉伯数字,我尝试了以下代码,但它不起作用。如何解决?

演示:http: //jsfiddle.net/NdzHg/

<script type="text/javascript">
    var interval = self.setInterval("clock()", 1000);
    function clock() {
    var rep = {
        '0': '&#1776;',
        '1': '&#1777;',
        '2': '&#1778;',
        '3': '&#1779;',
        '4': '&#1780;',
        '5': '&#1781;',
        '6': '&#1782;',
        '7': '&#1783;',
        '8': '&#1784;',
        '9': '&#1785;',
    }

        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>
​
4

1 回答 1

3

试试看:http: //jsfiddle.net/McxL5/ 顺便说一句,它在 mootools 中......

这是 jquery 版本:http: //jsfiddle.net/McxL5/12/

于 2012-04-06T17:28:38.780 回答