Meu site tem um script ASP para pegar a hora (hora e minuto) do servidor, como fazer para manter essa atualizada?
Ps.: <meta http-equiv="refresh" content="1;nome da página.asp"> não pode ser! Não posso ficar dando reload na minha página dessa forma.
Valeu!
Hora Atualizada?
Started By Flaviolrf, 27/05/2003, 14:37
6 replies to this topic
#1
Posted 27/05/2003, 14:37
Abraços,
Flávio França.
Flávio França.
#2
Posted 27/05/2003, 14:48
cara, tem um script do java que mostra a hora e atualiza constantemente, mas num lembro qual q é, tenta procurar no forum de javascript...
mas a propósito, oq vc quer fazer com essa data???
mas a propósito, oq vc quer fazer com essa data???
Marcelo Pereira Ramos Rodrigues
Delphi Developer
CCE da Amazônia
Delphi Developer
CCE da Amazônia
#3 Marcos Sanches
Posted 27/05/2003, 14:55
este codigo e em javascript mas te traz a data e a hora atualizada.....
<head>
<title>Data e Hora</title>
<script language="JavaScript">
<!--
function namosw_init_clock()
{
var type, i, top, obj, clocks;
clocks = new Array();
for (i = 0, top = 0; i < namosw_init_clock.arguments.length; i += 2) {
obj = eval('document.'+namosw_init_clock.arguments[i]);
if (obj == null) continue;
if ((type = namosw_init_clock.arguments[i+1]) < 1 && 11 < type) continue;
clocks[top++] = obj;
clocks[top++] = type;
}
clocks.months = new Array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho',
'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
clocks.days = new Array('Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira',
'Quinta-feira', 'Sexta-feira', 'Sábado');
clocks.k_days = new Array('ÀÏ', '¿ù', 'È', '¼ö', '¸ñ', '±Ý', 'Åä');
clocks.ampm_str = new Array('AM', 'PM');
clocks.k_ampm_str = new Array('¿ÀÀü', '¿ÀÈÄ');
if (top > 0) {
document.namosw_clocks = clocks;
namosw_clock();
}
}
function namosw_clock()
{
var i, type, clocks, next_call, str, hour, now, year2, year4;
clocks = document.namosw_clocks;
if (clocks == null) return;
next_call = false;
for (i = 0; i < clocks.length; i += 2) {
obj = clocks[i];
type = clocks[i+1];
now = new Date();
year2 = now.getYear();
year4 = year2;
if (year2 < 1000) year4 = 1900 + year2;
if (year2 >= 100) year2 = year4;
if (type == 1 || type == 2) {
obj.value = now.getDate() + ' de ' + clocks.months[now.getMonth()] + ' de ' + year4;
if (type == 2)
obj.value = clocks.days[now.getDay()] + ' ' + obj.value;
} else if (type == 3 || type == 4) {
obj.value = year2 + '/' + (now.getMonth()+1) + '/' + now.getDate();
} else if (type == 5 || type == 6) {
obj.value = now.getDate() + '/' + (now.getMonth()+1) + '/' + year2;
} else if (type == 8 || type == 9 || type == 10 || type == 11) {
obj.value = year4 + '³â ' + (now.getMonth()+1) + '¿ù ' + now.getDate() + 'ÀÏ';
if (type == 9)
obj.value += ' ' + clocks.k_days[now.getDay()] + '¿äÀÏ';
}
if (type == 4 || type == 6 || type == 7 || type == 10 || type == 11) {
hour = now.getHours();
if (type == 10 || type == 11) {
str = hour+'½Ã '+ now.getMinutes() +'ºÐ';
if (type == 11) str += ' ' + now.getSeconds() +'ÃÊ';
} else {
str = hour +':'+ ((now.getMinutes() < 10) ? '0'+now.getMinutes():now.getMinutes()) +':'+ ((now.getSeconds() < 10) ? '0'+now.getSeconds():now.getSeconds());
}
if (type == 7) obj.value = str;
else obj.value += ' ' + str;
}
if (type == 4 || type == 6 || type == 7 || type == 10 || type == 11)
next_call = true;
}
if (next_call)
window.setTimeout("namosw_clock();", 1000);
}
// -->
</script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red" OnLoad="namosw_init_clock('form1.textclock1', 6)">
<form name="form1">
<p><input type="text" name="textclock1" size="40"></p>
</form>
Espero ter ajudado.....
<head>
<title>Data e Hora</title>
<script language="JavaScript">
<!--
function namosw_init_clock()
{
var type, i, top, obj, clocks;
clocks = new Array();
for (i = 0, top = 0; i < namosw_init_clock.arguments.length; i += 2) {
obj = eval('document.'+namosw_init_clock.arguments[i]);
if (obj == null) continue;
if ((type = namosw_init_clock.arguments[i+1]) < 1 && 11 < type) continue;
clocks[top++] = obj;
clocks[top++] = type;
}
clocks.months = new Array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho',
'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
clocks.days = new Array('Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira',
'Quinta-feira', 'Sexta-feira', 'Sábado');
clocks.k_days = new Array('ÀÏ', '¿ù', 'È', '¼ö', '¸ñ', '±Ý', 'Åä');
clocks.ampm_str = new Array('AM', 'PM');
clocks.k_ampm_str = new Array('¿ÀÀü', '¿ÀÈÄ');
if (top > 0) {
document.namosw_clocks = clocks;
namosw_clock();
}
}
function namosw_clock()
{
var i, type, clocks, next_call, str, hour, now, year2, year4;
clocks = document.namosw_clocks;
if (clocks == null) return;
next_call = false;
for (i = 0; i < clocks.length; i += 2) {
obj = clocks[i];
type = clocks[i+1];
now = new Date();
year2 = now.getYear();
year4 = year2;
if (year2 < 1000) year4 = 1900 + year2;
if (year2 >= 100) year2 = year4;
if (type == 1 || type == 2) {
obj.value = now.getDate() + ' de ' + clocks.months[now.getMonth()] + ' de ' + year4;
if (type == 2)
obj.value = clocks.days[now.getDay()] + ' ' + obj.value;
} else if (type == 3 || type == 4) {
obj.value = year2 + '/' + (now.getMonth()+1) + '/' + now.getDate();
} else if (type == 5 || type == 6) {
obj.value = now.getDate() + '/' + (now.getMonth()+1) + '/' + year2;
} else if (type == 8 || type == 9 || type == 10 || type == 11) {
obj.value = year4 + '³â ' + (now.getMonth()+1) + '¿ù ' + now.getDate() + 'ÀÏ';
if (type == 9)
obj.value += ' ' + clocks.k_days[now.getDay()] + '¿äÀÏ';
}
if (type == 4 || type == 6 || type == 7 || type == 10 || type == 11) {
hour = now.getHours();
if (type == 10 || type == 11) {
str = hour+'½Ã '+ now.getMinutes() +'ºÐ';
if (type == 11) str += ' ' + now.getSeconds() +'ÃÊ';
} else {
str = hour +':'+ ((now.getMinutes() < 10) ? '0'+now.getMinutes():now.getMinutes()) +':'+ ((now.getSeconds() < 10) ? '0'+now.getSeconds():now.getSeconds());
}
if (type == 7) obj.value = str;
else obj.value += ' ' + str;
}
if (type == 4 || type == 6 || type == 7 || type == 10 || type == 11)
next_call = true;
}
if (next_call)
window.setTimeout("namosw_clock();", 1000);
}
// -->
</script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red" OnLoad="namosw_init_clock('form1.textclock1', 6)">
<form name="form1">
<p><input type="text" name="textclock1" size="40"></p>
</form>
Espero ter ajudado.....
#4
Posted 27/05/2003, 15:10
Tenho um javascript que mostra a hora atual
Tomara que te sirva
Até mais...
<div id=Clock align=center style="font-family: verdana; font-size: 10; color:red"> </div> <script> function tick() { var hours, minutes, seconds, ap; var intHours, intMinutes, intSeconds; var today; today = new Date(); intHours = today.getHours(); intMinutes = today.getMinutes(); intSeconds = today.getSeconds(); if (intHours == 0) { hours = "12:"; ap = "Meia Noite"; } else if (intHours < 12) { hours = intHours+":"; ap = "A.M."; } else if (intHours == 12) { hours = "12:"; ap = ""; } else { intHours = intHours - 12 hours = intHours + ":"; ap = "P.M."; } if (intMinutes < 10) { minutes = "0"+intMinutes+":"; } else { minutes = intMinutes+":"; } if (intSeconds < 10) { seconds = "0"+intSeconds+" "; } else { seconds = intSeconds+" "; } timeString = hours+minutes+seconds+ap; Clock.innerHTML = timeString; window.setTimeout("tick();", 100); } window.onload = tick; </script>
Tomara que te sirva
Até mais...
Elaine
WebDesigner e Produtora Multimídia
ecbert@ig.com.br
Por que cometer erros antigos se há tantos erros novos a escolher?
WebDesigner e Produtora Multimídia
ecbert@ig.com.br
Por que cometer erros antigos se há tantos erros novos a escolher?
#5
Posted 27/05/2003, 16:20
A hora em JS é legal, mas se o micro do usuário estiver com o relógio atrasado, a hora do site ficará atrasada tb. Preciso que seja em ASP, pois esse pegará a hora do servidor e não do cliente!
Abraços,
Flávio França.
Flávio França.
#6
Posted 27/05/2003, 16:42
para que vc queria usar essa data?
Marcelo Pereira Ramos Rodrigues
Delphi Developer
CCE da Amazônia
Delphi Developer
CCE da Amazônia
#7
Posted 27/05/2003, 22:49
Simples fato de mostrá-la ao usuário e tb por fazer parte do design (a forma como essa aparece).para que vc queria usar essa data?
Abraços,
Flávio França.
Flávio França.
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)