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 2176 取(m堆)石子游戏 (尼姆博奕)
    HDU 1846 Brave Game (巴什博弈)
    HDU-1025 Constructing Roads In JGShining's Kingdom
    FOJ有奖月赛-2015年11月 Problem B 函数求解
    FOJ有奖月赛-2015年11月 Problem A
    JXNU acm选拔赛 不安全字符串
    JXNU acm选拔赛 涛神的城堡
    JXNU acm选拔赛 涛涛的Party
    JXNU acm选拔赛 壮壮的数组
    JXNU acm选拔赛 最小的数
  • 原文地址:https://www.cnblogs.com/zhuangwf/p/5945227.html
Copyright © 2011-2022 走看看