<!DOCTYPE html>
    <html> 
        <head>
            <title>Cronometro</title>
        </head>
    <body>
<div id="Hora"></div>

<script>
    function crono(){
        var elCrono;
        var miFecha=new Date();
        horas=miFecha.getHours();
        min=miFecha.getMinutes();
        seg=miFecha.getSeconds();
        if (horas>12) {
            momento="pm";
            horas-=12;
        }
        else {
            momento="am";
        }
        if (horas<10) horas="0"+horas;
        if (min<10) min="0"+min;
        if (seg<10) seg="0"+seg;
        document.getElementById("Hora").innerHTML=horas+":"+min+":"+seg+" "+momento;
    }
window.onload=function(){
    elCrono=setInterval(crono,1000);
}
</script>
</body>
</html>

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *