刚刚在做后台页面最上面要动态显示时间刚写了这个代码

将这段代码加入<head></head>

<!--时间显示代码 -->
<script>
function clockon(contentDate){    
var now = new Date();    
var year = now.getYear();    
var month = now.getMonth();    
var date = now.getDate();    
var day = now.getDay();    
var hour = now.getHours();    
var minu = now.getMinutes();    
var sec = now.getSeconds();   
var week;     
month = month+1;    
if(month<10)month="0"+month;    
if(date<10)date="0"+date;    
if(hour<10)hour="0"+hour;    
if(minu<10)minu="0"+minu;    
if(sec<10)sec="0"+sec;    
//var arr_week = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");     
//week = arr_week[day];    这里显示星期几,我不用所以注释掉了
var time = "";    
time = year+"-"+month+"-"+date+"&nbsp;"+hour+":"+minu+":"+sec;

//time = year+"-"+month+"-"+date+"week"+hour+":"+minu+":"+sec;   如果需要显示周几的话可以用这句代码
if(document.all){        
 contentDate.innerHTML=""+time+""    }    
var timer = setTimeout("clockon(contentDate)",200);            
}</script>
<!--时间显示代码 -->

需要显示时间的地方代码如下:<div align="right" id="contentDate" ></div>

js实时显示系统时间的更多相关文章

  1. Qt 实时显示系统时间

    前言 我们用一个label控件来实时显示系统时间,用到 QTimer 和 QDateTime 这个两个类. 正题 头文件: #ifndef MAINWINDOW_H #define MAINWINDO ...

  2. Android学习总结——实时显示系统时间

    我们都知道System.currentTimeMillis()可以获取系统当前的时间,这里要实时显示就可以开启一个线程,然后通过handler发消息,来实时的更新TextView上显示的系统时间.具体 ...

  3. 用JS实现实时显示系统时间

    废话我就不多说了,直接上图和代码了 效果图: 代码视图: 下面为大家附上代码,复制即可用: <!DOCTYPE html> <html lang="en"> ...

  4. php随笔6-thinkphp OA系统 JS 实时显示当前时间

    不多说,直入主题: JS. // JavaScript Document function showtime() { var today,hour,second,minute,year,month,d ...

  5. js实现显示系统时间的表盘

    核心: 1,document.styleSheets 修改css里的keyframes属性值 2,表针角度的计算 最终显示效果: <!DOCTYPE html> <html> ...

  6. [linux]top命令详解-实时显示系统中各个进程的资源占用状况

    简介 top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器. top显示系统当前的进程和其他状况,是一个动态显示过程,即可以通过用户按 ...

  7. vue实时显示当前时间且转化为“yyyy-MM-dd hh:mm:ss”格式

    在实际运用中时间格式"yyyy-MM-dd hh:mm:ss"用的最多,如果需要其他格式可根据需求自行修改,下面直接上代码: 引入相应的js即可运行 <!DOCTYPE ht ...

  8. 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317         这个功能 ...

  9. JavaScript实时显示当前时间的例子

    用javascript代码在当前页面中实时显示当前时间.代码如下: <html> <head> <title>JavaScript 实时显示当前时间-www.jbx ...

随机推荐

  1. UML关系总结

    用例图: 1.扩展关系:如果已有一个用例,在这个用例的基础(该用例是完整的)上加入新的动作形成了另一个用例,即后者是通过继承前者的属性并加入新的内容而来的,则前者通常称为通用化用例,后者常为扩展用例. ...

  2. Sybase IQ数据库索引

    IQ是Sybase公司推出的特别为数据仓库.决策支持分析.数据分析/挖掘等查询分析密集型应用而设计的关系型数据库.IQ的架构与大多数关系型数据库不同,它特别的设计用以支持大量并发用户的即席查询.统计分 ...

  3. PAT (Advanced Level) 1050. String Subtraction (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  4. JAVA基础--容器 Set, List, Map

    Colections接口, Iterator接口, Set接口, List接口, Comparable接口, Map接口 Collections类 容器:装各种对象. 所有容器都在java.util里 ...

  5. spring+hibernate中的Result object returned from HibernateCallback isn't a List

    Ok the problem is that for executeFind() the return type is List....so there is no way to use unique ...

  6. Total Highway Distance

    Total Highway Distance 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi and Little Ho are playing a ...

  7. CodeForces 614B Gena's Code

    #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm& ...

  8. ICE第三篇------一些疑难点

    1 间接代理 参考http://blog.sina.com.cn/s/blog_53e8499c0100lkoo.html IceGrid用于支持分布式网络服务应用,一个IceGrid域由一个注册表( ...

  9. Alcatraz:插件管理

    安装: 终端粘贴 "curl -fsSL https://raw.github.com/alcatraz/Alcatraz/master/Scripts/install.sh | sh&qu ...

  10. 关于NOMINMAX这个预处理宏

    标准库在<algorithm>头中定义了两个模板函数std::min() 和 std::max().通常用它可以计算某个值对的最小值和最大值.可惜在 Visual C++ 无法使用它们,因 ...