时间操作(JavaScript版)—页面显示格式:年月日 时分秒 星期
2014-06-27 14:22
591 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>显示格式:年月日 时分秒 星期</title> <meta http-equiv="content-type" content="text/html; charset=gb2312"/> <script type="text/javascript"> 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); }; } </script> </head> <body> <span id="clock"></span> <script type="text/javascript"> var clock = new Clock(); clock.display(document.getElementById("clock")); </script> </body> </html>
相关文章推荐
- 时间操作(JavaScript版)—页面显示格式:年月日 上午下午 时分秒 星期
- 时间操作(JavaScript版)—页面显示格式:年月日 上午下午 时分秒 星期
- 时间操作(JavaScript版)—页面显示格式:年月日星期几
- 在移动的div中显示年月日时分秒星期,并计算当前页面活动时间
- 年月日时分秒加星期即时显示的JS日期时间特效
- jsp页面上只显示创建时间的年月日而不显示时分秒
- 关于时间的操作(JavaScript版)——年月日三级级联(默认依次显示请选择年、请选择月和请选择日)
- 在前台页面将时间戳改成年月日时分秒显示
- 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)
- Android动态显示系统时间,附获得当前年月日星期时分秒方法,一步到位
- 时间操作(JavaScript版)—年月日三级级联(默认依次显示请选择年、请选择月和请选择日)
- c#.net 获取时间年月日时分秒格式
- ExtJS时间扩展控件(显示年月日时分秒)
- JS 动态显示年月日星期时分秒
- 关于jsp页面显示的时间格式和Oracle数据库中的格式不一样的问题
- 解决ibatis查询时间只显示年月日,不显示时分秒的方法
- 兼容 火狐 IE 的JS时间控件 任意格式 年月日时分秒
- 后台用js显示年月日时分秒星期
- jsp页面时间显示格式
- spring mvc 在jsp页面如何使时间以格式yyyy-MM-dd HH:mm:ss显示,24小时制