js显示当前系统时间+星期几

<pre name="code" class="html"><!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
<head>
    <script>
        function displayDate()
        {
            var date = new Date();
            var year = date.getFullYear();
            var mouths = date.getMonth()+1;
            var day = date.getDate();
            var hours =  date.getHours();
            var minutes =  date.getMinutes();
            var seconds = date.getSeconds();
            var weekDay = new Array(7);
            weekDay[0] = "星期日";
            weekDay[1] = "星期一";
            weekDay[2] = "星期二";
            weekDay[3] = "星期三";
            weekDay[4] = "星期四";
            weekDay[5] = "星期五";
            weekDay[6] = "星期六";
            document.getElementById("demo").innerHTML="今天是:"+year+"年"+mouths+"月"+day+"日"+hours+":"+minutes+":"+seconds+" "+weekDay[date.getDay()];
            //获得当前时间,刻度为一千分一秒
            var timeID = setTimeout(displayDate,1000);
        }
    </script>
    <title></title>
</head>
<body οnlοad="displayDate()">
<p id="demo"></p>
</body>
</html>

运行结果:




                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值