最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS控制日期顯示的小例子

 更新時(shí)間:2013年11月23日 15:14:48   作者:  
這篇文章主要介紹了JS控制日期顯示的小例子,有需要的朋友可以參考一下

我們?cè)陧?xiàng)目中一般會(huì)遇到顯示時(shí)間的問(wèn)題,一般的處理方式是在前臺(tái)通過(guò)JS控制,JS控制顯示時(shí)間的代碼如下,各種不同的顯示方式:

復(fù)制代碼 代碼如下:

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 "現(xiàn)在是:" + this.year + "年" + this.month + "月" + this.date + "日 " + this.hour + ":" + this.minute + ":" + this.second + " " + this.day;
 };//現(xiàn)在是<SPAN id=clock>現(xiàn)在是:2013年3月6日 13:54:17 星期三</SPAN>

復(fù)制代碼 代碼如下:

<SPAN></SPAN>
 this.toSimpleDate = function() {
  return this.year + "-" + this.month + "-" + this.date;
 };//2013-03-06

 this.toDetailDate = function() {
  return this.year + "-" + this.month + "-" + this.date + " " + this.hour + ":" + this.minute + ":" + this.second;
 };//2013-03-06 13:45:43

 this.display = function(ele) {
  var clock = new Clock();
  ele.innerHTML = clock.toString();//顯示方式調(diào)用
  window.setTimeout(function() {clock.display(ele);}, 1000);
 };
}

相關(guān)文章

最新評(píng)論

平和县| 镇远县| 德保县| 石楼县| 通海县| 怀集县| 井研县| 黎城县| 普宁市| 淳安县| 民勤县| 中宁县| 南丰县| 盐亭县| 栖霞市| 奈曼旗| 郑州市| 浮梁县| 枝江市| 平昌县| 获嘉县| 当雄县| 隆子县| 铜川市| 革吉县| 荥经县| 大足县| 松溪县| 马山县| 井陉县| 黎平县| 铁岭县| 揭东县| 安福县| 叶城县| 青河县| 宁远县| 留坝县| 新巴尔虎左旗| 崇礼县| 灌阳县|