标签:div date() set new time innerhtml doc min html
<div id="m_tiem">PM 14:26</div>
tiem(‘m_tiem‘);
//pm am 12小时格式化
function tiem(id) {
var obj = window.document.getElementById(id);
var date = new Date();
var h = date.getHours();
var mm = date.getMinutes();
var str;
if(h > 12){
str = ‘PM‘;
}else {
str = ‘AM‘;
}
obj.innerHTML = str +‘ ‘+ h + ":" + mm
setTimeout("tiem(‘"+ id +"‘)",1000);
}
标签:div date() set new time innerhtml doc min html
原文地址:http://www.cnblogs.com/opcec/p/7650415.html