zoukankan      html  css  js  c++  java
  • JS 显示动态更新时间

    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>JS JavaScript 显示动态更新时间</title>
    </head>

    <body>
    <Script language="JavaScript"> <!--
    var enabled = 0;
    today
    = new Date();
    var day;
    var date;
    if(today.getDay()==0)
    day
    = "星期日";
    if(today.getDay()==1)
    day
    = "星期一 ";
    if(today.getDay()==2)
    day
    = "星期二 ";
    if(today.getDay()==3)
    day
    = "星期三 ";
    if(today.getDay()==4)
    day
    = "星期四 ";
    if(today.getDay()==5)
    day
    = "星期五 ";
    if(today.getDay()==6)
    day
    = "星期六 ";
    document.fgColor
    = " FF0072";
    date1
    =(today.getYear()) + "" + (today.getMonth() + 1 ) + "" + today.getDate() + "" ;
    date2
    = day ;
    document.write(date1.fontsize(
    2));
    document.write(date2.fontsize(
    2));
    document.write(
    "<span id='clock'></span>");
    var now,hours,minutes,seconds,timeValue;
    function showtime(){
    now
    = new Date();
    hours
    = now.getHours();
    minutes
    = now.getMinutes();
    seconds
    = now.getSeconds();
    timeValue
    = (hours >= 12) ? "下午 " : "上午 ";
    timeValue
    += hours+ ":";
    timeValue
    += ((minutes < 10) ? "0" : "") + minutes + ":";
    timeValue
    += ((seconds < 10) ? "0" : "") + seconds + "";
    clock.innerHTML
    = timeValue;
    setTimeout(
    "showtime()",100);
    }
    showtime();
    -->
    </Script>
    </body>
    </html>


       本人博客的文章大部分来自网络转载,因为时间的关系,没有写明转载出处和作者。所以在些郑重的说明:文章只限交流,版权归作者。谢谢

  • 相关阅读:
    MyEclipse编码集设置
    Tomcat内存溢出问题解决
    避免头文件多次编译
    C++指针学习(1)
    C++头文件和实现(用复数类举例)
    从helloworld开始
    标准库string类型
    浅谈Lua的Coroutine协程的多"线程"并发模型
    关于闭包函数的概念和原理
    笔记
  • 原文地址:https://www.cnblogs.com/wzg0319/p/1693731.html
Copyright © 2011-2022 走看看