js动态获取时间
<script language="javascript" type="text/javascript">
function show_date_time(){
window.setTimeout("show_date_time()", 1000);
var now = new Date(); //獲取系統(tǒng)日期
//獲取時(shí)間
var YY=now.getFullYear();
var MM=now.getMonth()+1;
var DD=now.getDate();
var WW=now.getDay();
var hh = now.getHours(); //獲取小時(shí)
var mm = now.getMinutes(); //獲取分鐘
var ss = now.getTime() % 60000; //獲取時(shí)間,因?yàn)橄到y(tǒng)中時(shí)間是以毫秒計(jì)算的,
//所以秒要通過余60000得到。
ss = (ss - (ss % 1000)) / 1000; //然后,將得到的毫秒數(shù)再處理成秒
span_dt_dt.innerHTML=YY+"年"+MM+"月"+DD+"日"+"/? "+"星期"+WW+"/ "+hh+"時(shí)"+mm+"分"+ss+"秒";//+now
}
show_date_time();
</script>
?
<body>
??????? 現(xiàn)在時(shí)間:<span id="span_dt_dt" ></span>
</body>
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/goodsunny/p/3445898.html
總結(jié)
- 上一篇: eclipse连接小米2调试程序的问题
- 下一篇: 垂直居中