zoukankan      html  css  js  c++  java
  • js显示当前时间

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
         <script type="text/javascript" src="jquery-1.8.3.min.js"></script>
          <script type="text/javascript">
            //获取当前时间并拼接放到div中的函数
              function nowTime(){
                  var nowDate = new Date();
                  var year = nowDate.getFullYear();
                  var month = nowDate.getMonth()+1;
                  month = month>9 ? month : "0" + month;
                  var date = nowDate.getDate();
                  date = date>9 ? date : "0" + date;
                  var hour = nowDate.getHours();
                  hour = hour>9 ? hour : "0" + hour;
                  var miunte = nowDate.getMinutes();
                  miunte = miunte>9 ? miunte : "0" + miunte;
                  var second = nowDate.getSeconds();
                  second = second>9 ? second : "0" + second;
                  
                  $("#time").text(year+"年"+month+"月"+date+"日"+hour+"时"+miunte+"分"+second+"秒");
              }
              //加载后执行一次函数,以后每秒再执行
              $(function(){
                  nowTime();
                  setInterval("nowTime()", 1000);
              });
          </script>
    </head>
    <body>
            <div id="time"></div>
    </body>
    </html>

  • 相关阅读:
    hdu acm 2844 Coins 解题报告
    hdu 1963 Investment 解题报告
    codeforces 454B. Little Pony and Sort by Shift 解题报告
    广大暑假训练1 E题 Paid Roads(poj 3411) 解题报告
    hdu acm 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
    hdu acm 1114 Piggy-Bank 解题报告
    poj 2531 Network Saboteur 解题报告
    数据库范式
    ngnix 配置CI框架 与 CI的简单使用
    Vundle的安装
  • 原文地址:https://www.cnblogs.com/zhuangwf/p/5945227.html
Copyright © 2011-2022 走看看