js 时间表

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>表</title>
</head>
<body>
    <div id="biao"></div>
    <script type="text/javascript">
    var a=setInterval("clock()",1000)               //第一个参数为函数方法  第二个为1秒
    function clock(){
        var nian= new Date().getFullYear();     // 获取当前年
        var yue= new Date().getMonth()+1;       // 获取当前月
        var ri= new Date().getDate();            // 获取当前日
        var shi= new Date().getHours();            // 获取当前时
        var fen= new Date().getMinutes();        // 获取当前分
        var miao= new Date().getSeconds();        // 获取当前秒
        var xq1=new Date();                
        var xq=["","","","","","",""]     //把数字改成汉字
        if(yue<10){
            yue="0"+yue
        }
        if(miao<10){
            miao="0"+miao
        }
        if(shi<10){
            shi="0"+shi
        }
        if(fen<10){
            fen="0"+fen
        }
        if(ri<10){
            ri="0"+ri
        }
        document.getElementById("biao").innerHTML=nian+""+yue+""+ri+""+shi+""+fen+""+miao+""+"星期"+xq[xq1.getDay()]

    }
    </script>
</body>
</html>
原文地址:https://www.cnblogs.com/zhaoxialong/p/8259137.html