Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/04/2014, 04:34
josemari75
 
Fecha de Ingreso: mayo-2013
Mensajes: 19
Antigüedad: 11 años
Puntos: 0
Respuesta: cojer la hora del servidor

hola, los datos los mando por post a un archivo php, bueno, se llamarlo, me explico mejor:
este es el codigo en html con java script para la fecha:

<html>
<head>
<title> Fecha actual 2 </title>
</head>

<body>

<script>

var mydate=new Date();
var year=mydate.getYear();
if (year < 1000)
year+=1900;
var day=mydate.getDay();
var month=mydate.getMonth()+1;
if (month<10)
month="0"+month;
var daym=mydate.getDate();
if (daym<10)
daym="0"+daym;
document.write("<small><font color='000000' face='Arial'><b>"+daym+"/"+month+"/"+year+"</b></font></small>")

</script>

</body>
</html>

y este para la hora:

<html>
<head>
<title>
</title>

<script language="JavaScript">
function mueveReloj(){
momentoActual = new Date()
hora = momentoActual.getHours()
minuto = momentoActual.getMinutes()
segundo = momentoActual.getSeconds()

str_segundo = new String (segundo)
if (str_segundo.length == 1)
segundo = "0" + segundo

str_minuto = new String (minuto)
if (str_minuto.length == 1)
minuto = "0" + minuto

str_hora = new String (hora)
if (str_hora.length == 1)
hora = "0" + hora

horaImprimible = hora + " : " + minuto + " : " + segundo

document.form_reloj.reloj.value = horaImprimible

setTimeout("mueveReloj()",1000)
}
</script>

<script language="JavaScript">
function mueveFecha(){

}
</script>

</head>


<body onload="mueveReloj()"; onload="mueveFecha()">
<div align="center">
<form name="form_reloj">
<input type="text" name="reloj" size="24" style="color : Black;text-align : center;" onfocus="window.document.form_reloj.reloj.blur()">

</form>

</div>

</body>
</html>

ahora bien, este codigo es una mezcla de codigos que encontre buscando...... en la fecha me sale como un "texto" y la hora como un input, lo que me gustaria es cambiar lo de la fecha tambien a un input y asi mandar los dos datos en el post al php (vamos, suponiendo que sea buena idea) luego en el php creo que podria cojerlo para utilizarlo.
gracias