Ir ao conteúdo
  • Cadastre-se

Data e hora em PHP! (Resolvido)


___

Posts recomendados

Coloquei esse arquivo e salvei com extensão .php. Só que quero que apareça os segundos tambem e que ele seja atualizado a cada 1 segundo.

<html>

<head><title>v</title>

</head>

<body>

<?

$data = date("d/m/y");

$hora = date("h/i");

echo "$hora/n $data"

?>

</body>

</html>

Link para o comentário
Compartilhar em outros sites

para atualizar automático tem que usar java script:



<html>
<title>Modelo com relogio</title>
<script language="javascript"><!--W3e JAVAscript Preset
var timerID = null;
var timerRunning = false;
function stopclock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false;
}

function startclock()
{
    stopclock();
    showtime();
}

function showtime()
{
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var timeValue = "" + ((hours > 12) ? hours - 12 : hours);
    timeValue  += ((minutes < 10) ? ":0" : ":") + minutes;
    timeValue  += ((seconds < 10) ? ":0" : ":") + seconds;
    timeValue  += (hours >= 12) ? " P.M." : " A.M.";
    document.clock.face.value = timeValue;
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;
}
//-->
</script>

<form name="clock" onSubmit="0">
  <input type="text" name="face" size="12">
</form>
<body>
<script>startclock();</script>

</body>
</html>

Link para o comentário
Compartilhar em outros sites

para atualizar automático tem que usar java script:



<html>
<title>Modelo com relogio</title>
<script language="javascript"><!--W3e JAVAscript Preset
var timerID = null;
var timerRunning = false;
function stopclock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false;
}

function startclock()
{
    stopclock();
    showtime();
}

function showtime()
{
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var timeValue = "" + ((hours > 12) ? hours - 12 : hours);
    timeValue  += ((minutes < 10) ? ":0" : ":") + minutes;
    timeValue  += ((seconds < 10) ? ":0" : ":") + seconds;
    timeValue  += (hours >= 12) ? " P.M." : " A.M.";
    document.clock.face.value = timeValue;
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;
}
//-->
</script>

<form name="clock" onSubmit="0">
  <input type="text" name="face" size="12">
</form>
<body>
<script>startclock();</script>

</body>
</html>

Só da para fazer dentro de um campo de texto do formulário?

Não daria para fazer dentro de uma div por exemplo?

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!