My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hora del Servidor</title>
<script type="text/javascript">
// Recogemos la fecha del servidor.
var fecha = "<%=Now()%>";
// Pasamos la fecha a javascript
var fecha_js = new Date(fecha);

var segundos = fecha_js.getSeconds();
var hora = fecha_js.getHours();
var minutos = fecha_js.getMinutes();

function mostrar() {

// Ha pasado un segundo
segundos++;

if (segundos == 60) {
segundos = 0;
minutos++;
if (minutos == 60) {
minutos = 0;
hora++;
if (hora == 24) {
hora = 0;
}
}
}

if ((hora >= 0)&&(hora <= 9)){
hora="0"+hora;
if (hora == 0)
hora = "00";
}

if ((minutos >= 0)&&(minutos <= 9)){
minutos="0"+minutos;
}

if ((segundos >= 0)&&(segundos <= 9)){
segundos="0"+segundos;
}

document.getElementById("hora").value = " " + hora + ":" + minutos + ":" + segundos;

window.setTimeout("mostrar()",1000);
}
</script>
</head>
<body onLoad="window.setTimeout('mostrar()',1000);">

<h1>Hora del Servidor</h1>


<form id="formulario">
<label for="hora">En estos momentos son las...</label>
<input type='text' id='hora' size=10/>
</form>



<br><br>
<hr>
Art&iacute;culo disponible en: <a href="http://lineadecodigo.com/asp/reloj-con-la-hora-del-servidor/">http://lineadecodigo.com/asp/reloj-con-la-hora-del-servidor/</a><br/>
<a href="http://lineadecodigo.com" title="Linea de Codigo">lineadecodigo.com</a>

</body>
</html>

Change log

r162 by vcuervo on Sep 3, 2009   Diff
Reloj con la hora del servidor
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1724 bytes, 71 lines
Powered by Google Project Hosting