js实时显示系统时间
刚刚在做后台页面最上面要动态显示时间刚写了这个代码
将这段代码加入<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+" "+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实时显示系统时间的更多相关文章
- Qt 实时显示系统时间
前言 我们用一个label控件来实时显示系统时间,用到 QTimer 和 QDateTime 这个两个类. 正题 头文件: #ifndef MAINWINDOW_H #define MAINWINDO ...
- Android学习总结——实时显示系统时间
我们都知道System.currentTimeMillis()可以获取系统当前的时间,这里要实时显示就可以开启一个线程,然后通过handler发消息,来实时的更新TextView上显示的系统时间.具体 ...
- 用JS实现实时显示系统时间
废话我就不多说了,直接上图和代码了 效果图: 代码视图: 下面为大家附上代码,复制即可用: <!DOCTYPE html> <html lang="en"> ...
- php随笔6-thinkphp OA系统 JS 实时显示当前时间
不多说,直入主题: JS. // JavaScript Document function showtime() { var today,hour,second,minute,year,month,d ...
- js实现显示系统时间的表盘
核心: 1,document.styleSheets 修改css里的keyframes属性值 2,表针角度的计算 最终显示效果: <!DOCTYPE html> <html> ...
- [linux]top命令详解-实时显示系统中各个进程的资源占用状况
简介 top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器. top显示系统当前的进程和其他状况,是一个动态显示过程,即可以通过用户按 ...
- vue实时显示当前时间且转化为“yyyy-MM-dd hh:mm:ss”格式
在实际运用中时间格式"yyyy-MM-dd hh:mm:ss"用的最多,如果需要其他格式可根据需求自行修改,下面直接上代码: 引入相应的js即可运行 <!DOCTYPE ht ...
- 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317 这个功能 ...
- JavaScript实时显示当前时间的例子
用javascript代码在当前页面中实时显示当前时间.代码如下: <html> <head> <title>JavaScript 实时显示当前时间-www.jbx ...
随机推荐
- Java 六种异常处理的陋习(转)
Java 六种异常处理的陋习 原文链接: http://www.cnblogs.com/Android-and-android/archive/2013/05/02/3054469.html 你觉得 ...
- C#获取IPv4代码
using System; using System.Collections.Generic; using System.Collections.Specialized; using System.C ...
- codeforces 665A Buses Between Cities
简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...
- Mac系统下安装Tomcat,以及终端出现No such file or directory的错误提示解决方案
Tomcat,作为一个免费的服务器口碑实在太好,本想安装一个研究研究,无奈电脑是mac系统,在网上搜了一些安装方法总是出错,直到遇到了这篇博客,http://www.cnblogs.com/qingy ...
- C# devExpress BandedGridView属性 备忘
BandedGridView属性备忘 StringBuilder sb = new StringBuilder(); DevExpress.XtraGrid.Views.BandedGrid.Band ...
- Shortest Path
Shortest Path Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 配置 php-fpm 监听的socket
一般现在我们配置的PHP的web环境,如LNMP(linux+Nginx+Mysql+PHP), 这里linux可能是centos, ubuntu..., 数据库可能是mysql, postgresq ...
- 找礼物(find)
找礼物(find) 题目描述 新年到了,你的好友和你(共K个人)的周围满是礼物,你让你的好友先拿,但是每个人只能拿当前离自己最近的礼物[当然如果有并列的多个礼物离你的距离相等(精确到小数点后四位,所有 ...
- 左倾堆(C#)
参考:http://www.cnblogs.com/skywang12345/p/3638384.html using System; using System.Collections.Generic ...
- strlen sizeof strcat strcpy区别
strlen(p): 能计算出p指向字符串的长度(以当前p的位置开始),不包含终止字符'\0': p可以声明为char* p或者char p[],这两种形式strlen均能正确计算. sizeof ...