FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


[Scripts] PHP Clock





yule
Use the following code where you want a clock to show up.

Code:
<?PHP
$time_offset ="0"; // you many need to change this to accomidate server time offset
$adj = ($time_offset * 120); // some simple math here.
$time = date(" h:i:s",time() + $adj); // remove seconds by simply gettting rid of the :s

echo "$time";

?>


Anything behind the // is a comment, so you can delete those if you want.
Grimboy
Of course if you want a real time clock then you'd be better off with javascript. This might be better off as a "page generated on x".
rohan2kool
Grimboy wrote:
Of course if you want a real time clock then you'd be better off with javascript. This might be better off as a "page generated on x".


I agree. This is better of as : This page was a genereated at x. However, using JavaScript, things would be more dynamic. Use this code:

Code:


<html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10)
  {i="0" + i}
  return i
}
</script>
</head>

<body onload="startTime()">
<div id="txt"></div>
</body>
</html>

Related topics
I want scripts please come here
Site Nav Suggestions...
i need help!!......
Google Site Map
php mailing script
Any good gallery scripts PHP
consulta sobre el hosting
Web Page Maker
Para programadores de PHP
Seguridad en mis scripts PHP
SimplytheBest Scripts
Les meilleurs scripts PHP
how to make a php nav
manda um site que tenha bons scripts php para cadastro
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.