Can somebody help change this so it's 12h clock? I have no idea how to work html

function dotime(){theTime=setTimeout('dotime()',1000);
d = new Date();
hr = d.getHours()+100;
mn = d.getMinutes()+100;
se = d.getSeconds()+100;
if(hr==100){hr=112;am_pm='am';}
else if(hr<112){am_pm='am';}
else if(hr==112){am_pm='pm';}
else if(hr>112){am_pm='pm';hr=(hr-0);}
tot=''+hr+mn+se;
document.hr1.src = 'Time/'+tot.substring(1,2)+'.png';
document.hr2.src = 'Time/'+tot.substring(2,3)+'.png';
document.mn1.src = 'Time/'+tot.substring(4,5)+'.png';
document.mn2.src = 'Time/'+tot.substring(5,6)+'.png';
document.ampm.src= 'Time/'+am_pm+'.png';}
dotime();