<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';
}
mm = mm < 10 ? "0" + mm : mm;
obj.innerHTML = str +' '+ h + ":" + mm
setTimeout("tiem('"+ id +"')",1000);
}