JS动态时间显示(包含星期)

来源:互联网 发布:ubuntu双系统grub修复 编辑:程序博客网 时间:2024/04/28 05:43
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><%@ page language="java" %><%@ page contentType="text/html;charset=UTF-8"%>    <head>    <title>JS动态时间显示</title>    <script type="text/javascript">        function $(id){            return document.getElementById(id);        }           function showTime(){            dt = new Date();            var show_day=new Array('星期一','星期二','星期三','星期四','星期五','星期六','星期日');            year=dt.getFullYear();            month=dt.getMonth()+1;            date=dt.getDate();            day=dt.getDay()-1;            hours=dt.getHours();            hours=hours<10?"0"+hours:hours;            minutes=dt.getMinutes();            minutes=minutes<10?"0"+minutes:minutes;            seconds=dt.getSeconds();            seconds=seconds<10?"0"+seconds:seconds;            dtime = "当前时间是:"+year+"年"+month+"月"+date+"日 "+hours+"点"+minutes+"分"+seconds+"秒 "+show_day[day];            $("nowTime").innerHTML = dtime;            setTimeout("showTime()",1000);        }    </script>    <style>         .time{            width:100%;            margin:200px auto;            border:3px red solid;            text-align:center;            font-size:42pt;            color:#6090dd;         }    </style>    </head>    <body onload="showTime()">        <div id="nowTime" class="time"></div>    </body></html>
0 0
原创粉丝点击