zoukankan      html  css  js  c++  java
  • 时钟JS用于时间滚动更新。小技巧

    function Clock() {
    	var date = new Date();
    	this.year = date.getFullYear();
    	this.month = date.getMonth() + 1;
    	this.date = date.getDate();
    	this.day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[date.getDay()];
    	this.hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
    	this.minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
    	this.second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
    
    	this.toString = function() {
    		return "现在是:" + this.year + "年" + this.month + "月" + this.date + "日 " + this.hour 
    + ":" + this.minute + ":" + this.second + " " + this.day; 
    	};
    	
    	this.toSimpleDate = function() {
    		return this.year + "-" + this.month + "-" + this.date;
    	};
    	
    	this.toDetailDate = function() {
    		return this.year + "-" + this.month + "-" + this.date + " " + this.hour + ":" 
    + this.minute + ":" + this.second;
    	};
    	
    	this.display = function(ele) {
    		var clock = new Clock();
    		ele.innerHTML = clock.toString();
    		window.setTimeout(function() {clock.display(ele);}, 1000);
    	};
    }
    

    本人声明: 个人主页:沐海(http://www.cnblogs.com/mahaisong) 以上文章都是经过本人设计实践和阅读其他文档得出。如果需要探讨或指教可以留言或加我QQ!欢迎交流!
  • 相关阅读:
    Handle类与线程
    android中ProgressBar和ListView
    RadioGroup、RadioButton、CheckBox、Toast用法
    Android开发中的menu菜单
    多个Activity相互调用和Intent
    ubuntu下安装h2数据库
    window下eclipse安装python插件
    centos7安装JDK1.8
    ubuntu设置root权限默认密码
    Linux给用户添加sudo权限
  • 原文地址:https://www.cnblogs.com/mahaisong/p/2193382.html
Copyright © 2011-2022 走看看