Ir ao conteúdo

Data e Hora - PHP e Javascript


Eder Cuer

Posts recomendados

Postado

Olá galera estou com uns problemas com a hora e a data do meu site. O site ta em testes ainda e já está alocado em um servidor, mas ta com a hora errada, se agora é 11:56, no site aparece 10:57, e nessa hora mostra os segundos também, e em tempo real, ta ai o codigo:



<?php
include("session.php");
include("security.php");
include_once("admin.config.inc.php");
if(isset($_SESSION['UsErOfAdMiN']))
$UsErOfAdMiN=$_SESSION['UsErOfAdMiN'];
$active=$_GET['active'];
?>


<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8"><LINK
href="main.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<SCRIPT LANGUAGE="JavaScript">

function MakeArrayday(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
this[i] = "";
return this;
}
function MakeArraymonth(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
this[i] = "";
return this;
}

var hours;
var minutes;
var seconds;
var timer=null;
function sClock(hours1,minutes1,seconds1)
{
hours=parseInt(hours1);
minutes=parseInt(minutes1);
seconds=parseInt(seconds1);
if(timer){clearInterval(timer);timer=null;}
timer=setInterval("work();",1000);
}

function twoDigit(_v)
{
if(_v<10)_v="0"+_v;
return _v;
}

function work()
{
if (!document.layers && !document.all && !document.getElementById) return;
var runTime = new Date();
var dn = "AM";
var shours = hours;
var sminutes = minutes;
var sseconds = seconds;
if (shours >= 12)
{
dn = "PM";
shours-=12;
}
if (!shours) shours = 12;
sminutes=twoDigit(sminutes);
sseconds=twoDigit(sseconds);
shours =twoDigit(shours );
movingtime = ""+ shours + ":" + sminutes +":"+sseconds+" " + dn;
if (document.getElementById)
document.getElementById("clock").innerHTML=movingtime;
else if (document.layers)
{
document.layers.clock.document.open();
document.layers.clock.document.write(movingtime);
document.layers.clock.document.close();
}
else if (document.all)
clock.innerHTML = movingtime;

if(++seconds>59)
{
seconds=0;
if(++minutes>59)
{
minutes=0;
if(++hours>23)
{
hours=0;
}
}
}
}
</script>


</HEAD>
<BODY bgColor="#22509f" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onLoad="sClock('<?=date("G");?>','<?=date("i");?>','<?=date("s");?>');">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=right height=5></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>

<TR>
<TD width="74%" height="42"><BR>
</TD>
<TD width="0%" align=middle noWrap class=w><span id=clock style="position:relative;"></span> </TD>
<td width="1%" id="onlinetime" style="display: none;"><?=date("H:i:s");?></td>
<TD noWrap align=middle width="0%"><IMG height=25
src="images/divdots.gif" width=3></TD>
<TD width="1%" align=middle noWrap class=w><? echo date("l, F d, Y"); ?></TD>
<TD noWrap align=middle width="0%"><IMG height=25
src="images/divdots.gif" width=3></TD>
<TD width="8%" align=middle noWrap class=w>Usuário Online: <B><? echo $UsErOfAdMiN; ?></B></TD>
<TD noWrap align=middle width="0%"><IMG height=25
src="images/divdots.gif" width=3></TD>
<TD width="3%" align=middle noWrap><A class=w
href="logout.php"
target=_top><B>Logout</B></A></TD>
<TD width="0%"> </TD></TR></TABLE></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=202><IMG height=1 src="images/spacer.gif" width=200
border=0></TD>
<?php
include("headlinks.txt.php");

$MainLinksSize = sizeof($HeadLinksArray);

for($i=0;$i<$MainLinksSize;$i++)
{

$LinkTitle = $HeadLinksArray[$i][0];
$HREF = $HeadLinksArray[$i][1];
?>
<TD width="15">
<TABLE width="100%" border=0 cellPadding=5 cellSpacing=0>
<TBODY>
<TR>
<TD align="middle" noWrap
class="<? if($active==$LinkTitle) echo "tab_on"; else echo "tab_s";?>">
<A class="<? if($active==$LinkTitle) echo "tab_o"; else echo "tab";?>"
href="<?php echo $HREF ?>"
target="_top"><?php echo $LinkTitle; ?></A></TD>
</TR>
</TBODY>
</TABLE>
</TD>
<?
}
?>


<TD > </TD>
</TR>
</TBODY></TABLE>
<p class="sitename"> </p></TD></TR></TBODY></TABLE></BODY></HTML>


Já tentei bastante mudar a hora, pesquisei muito, usei varias coisas e não deu certo, será que alguém pode me dar uma luz?

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...

LANÇAMENTO!

eletronica2025-popup.jpg


CLIQUE AQUI E BAIXE AGORA MESMO!