zoukankan      html  css  js  c++  java
  • 完整显示当前日期和时间的JS代码

     1 代码
     2 
     3 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> <script>
     4         function tick() {
     5             var hours, minutes, seconds, xfile;
     6             var intHours, intMinutes, intSeconds;
     7             var today, theday;
     8             today = new Date();
     9             function initArray() {
    10                 this.length = initArray.arguments.length
    11                 for (var i = 0; i < this.length; i++)
    12                     this[i + 1] = initArray.arguments[i]
    13             }
    14             var d = new initArray(
    15                 "星期日",
    16                 "星期一",
    17                 "星期二",
    18                 "星期三",
    19                 "星期四",
    20                 "星期五",
    21                 "星期六");
    22             theday = today.getFullYear() + "年" + [today.getMonth() + 1] + "月" + today.getDate() + d[today.getDay() + 1];
    23             intHours = today.getHours();
    24             intMinutes = today.getMinutes();
    25             intSeconds = today.getSeconds();
    26             if (intHours == 0) {
    27                 hours = "12:";
    28                 xfile = "午夜";
    29             } else if (intHours < 12) {
    30                 hours = intHours + ":";
    31                 xfile = "上午";
    32             } else if (intHours == 12) {
    33                 hours = "12:";
    34                 xfile = "正午";
    35             } else {
    36                 intHours = intHours - 12
    37                 hours = intHours + ":";
    38                 xfile = "下午";
    39             }
    40             if (intMinutes < 10) {
    41                 minutes = "0" + intMinutes + ":";
    42             } else {
    43                 minutes = intMinutes + ":";
    44             }
    45             if (intSeconds < 10) {
    46                 seconds = "0" + intSeconds + " ";
    47             } else {
    48                 seconds = intSeconds + " ";
    49             }
    50             timeString = theday + xfile + hours + minutes + seconds;
    51             Clock.innerHTML = timeString;
    52             window.setTimeout("tick();", 100);
    53         }
    54         window.onload = tick; 
    55     </script>
    <div id="Clock" align="center" style="font-size: 12px; color:#000000"></div> 
  • 相关阅读:
    Spring框架基本应用
    hibernate 多表查询
    myeclipse 中解决Hibernate 和Struts 2的冲突
    新建一个Tomcat服务器
    hibernate连接数据库
    MyEclipse从数据库逆向生成Hibernate实体类
    Struts 2 标签
    struts 2 框架的应用
    AutoIt: WinGetClassList可以把当前窗口所有的handle全部列出来
    自动化测试建议【转载,与我的想法完全雷同】
  • 原文地址:https://www.cnblogs.com/jthb/p/3831216.html
Copyright © 2011-2022 走看看