miércoles, 15 de marzo de 2017

reloj digital y fecha en pantalla

<!DOCTYPE>
<html lang='es'>
        <head>
            <title>reloj digital en pantalla</title>
                <meta charset='UTF-8'/>
                <meta name='description' content='Página web'>
                <meta name='keywords' content=',javascript, ejemplo, html'>
                <script type="text/javascript">
                //fecha
                    function fecha(){
                        Hoy=new Date();
                        Dia=""+Hoy.getDate() +" / "+ (Hoy.getMonth()+1)+"/"+(Hoy.getYear()+1900);//getfullYear
                        document.clock.dia.value=Dia;//mostramos el dia en la caja text   
            }
            //hora
            function hora(){
                var hoy= new Date();
                var horas= hoy.getHours();
                var minutos= hoy.getMinutes();
                var segundos=hoy.getSeconds();
                var timeValue;
                timeValue=""+((horas>12)?horas -12:horas);
                timeValue +=((minutos<10)?":0":":")+minutos;
                timeValue +=((segundos<10)?":0":":")+ segundos;
                timeValue +=(horas>=12)?" P.M.":" A:M.";
                document.clock.face.value=timeValue;//se puede cambiar la posición actual a la barra de estado poniendo
                window.status=timeValue;
                control=setTimeout("hora()",1000);
           
            }
            //declaración de variables
            var control= null;
            function InicioReloj() {
                fecha();
                hora();
            }
                </script>
        </head>   
            <body bgcolor="7AC6D0" onLoad="InicioReloj()">
            <center>
                <h2>Esto es un reloj hecho con javascript</h2>
                    <table border="1">
                        <tr>
                            <form name="clock" onSubmit="0">
                            <tr>
                                <td>Hoy es:<input type="text" name="dia" size="12" style="text-align:center" value=""></td>
                                <td>La hora es:<input type="text" name="face" size="12" style="text-align:center" value=""></td>
                               
                            </tr>
                            </form>
                        </tr>
                    </table>
            </center>
            <hr> <!--dibuja una linea horizontal-->
               
           
           
        </body>
    </html>

No hay comentarios:

Publicar un comentario