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

将这段代码加入<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. UISegmentedControl 踩坑

    @interface JLMyContactsViewController () @property (nonatomic, strong)   UIImageView *navImageView; ...

  2. ARM汇编指令的一些总结-转

    ARM汇编指令的一些总结ARM汇编指令很多,但是真正常用的不是很多,而且需要认真琢磨的又更少了.比较有用的是MOV B BL LDR STR还是通过具体汇编代码来学习吧.@ disable watch ...

  3. PAT (Advanced Level) 1068. Find More Coins (30)

    01背包路径输出. 保证字典序最小:从大到小做背包. #include<cstdio> #include<cstring> #include<cmath> #inc ...

  4. PAT (Advanced Level) 1056. Mice and Rice (25)

    简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...

  5. BNU OJ 50999 BQG's Approaching Deadline

    #include<cstdio> #include<algorithm> using namespace std; +; struct Homework { long long ...

  6. 从客户端检测到有潜在危险的 Reque

    web.config里面加上<httpRuntime requestValidationMode="2.0" />如下<system.web><htt ...

  7. iOS完美版的UIScrollView无缝循环:你值得一看

    可以直接copy运行研究 .m头文件和声明的常量(宏和const) #import "ViewController.h" // UIScrollView的尺寸 const CGFl ...

  8. Gamma原理及快速实现算法(C/C++)(转)

    源:Gamma原理及快速实现算法(C/C++) 原文:http://blog.csdn.net/lxy201700/article/details/24929013 参考 http://www.cam ...

  9. curl调用openstack API总结

    curl命令是Linux下一个可以使用多种协议收发数据的工具,包括http协议.openstack的API接口都是URL地址:http://controller:35357/v3可以使用curl命令进 ...

  10. Shell条件与测试

    分类参考 文件状态测试 -b filename 当filename 存在并且是块文件时返回真(返回0) -c filename 当filename 存在并且是字符文件时返回真 -d pathname ...