[Java教程]js 显示日期时间,时间过一秒加1
0 2017-10-25 11:00:10
html:
js:
1:引入js库
2:function showLocale(objD) { var str, colorhead, colorfoot; var yy = objD.getYear(); if (yy < 1900) yy = yy + 1900; var MM = objD.getMonth() + 1; if (MM < 10) MM = '0' + MM; var dd = objD.getDate(); if (dd < 10) dd = '0' + dd; var hh = objD.getHours(); if (hh < 10) hh = '0' + hh; var mm = objD.getMinutes(); if (mm < 10) mm = '0' + mm; var ss = objD.getSeconds(); if (ss < 10) ss = '0' + ss; var ww = objD.getDay(); if (ww == 0) colorhead = ""; if (ww > 0 && ww < 7) colorhead = "";str = colorhead + yy + "年" + MM + "月" + dd + "日 " + hh + ":" + mm + ":" + ss + " ";return (str);}function tick() {var today;today = new Date();document.getElementById("new_data").innerHTML = showLocale(today);window.setTimeout("tick()", 1000);}tick();
本文网址:http://www.shaoqun.com/a/329809.html
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:admin@shaoqun.com。
JS
0