If i have, for example, a marquee that displays time when i push a button,like this:

if($_POST['time'])
 echo "<marquee direction=right behavior=alternate scrolldelay=500 scrollamount=30>".date('d-m-Y').' GMT'.date('P').'  '.date('H:i:s')."</marquee>";

,it will display the time at the moment that i pushed the button. How could i make it to display the time continously?

Cheers

Recommended Answers

All 9 Replies

you go through javascript to make the change in time

i don't know too much js so...how can i do that?:-O

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>t</title>
</head>

<body>
<marquee direction=right behavior=alternate scrolldelay=500 scrollamount=30><div id="a"></div></marquee>
</body>
</html>
<script type="text/javascript">
function show()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM" 
if (hours>12)
{
dn="PM"
hours=hours-12
}
if (hours==0)
hours=12

if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds

document.getElementById('a').innerHTML= ""+hours+":"+minutes+":"+seconds+" "+dn +""
setTimeout("show()",1000)
}
show()
</script>

i think you find the answer

thank you,that works :)
i wrote a similar code (i think) and included the condition that the clock should appear when pushing a button...but when i push the button nothing happens...any ideas?:S

<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()">
<form method=post action=d.php>
<input type=submit value="Push for time!" name=time />
&nbsp&nbsp&nbsp
<input type=submit value="Push to stop time!" name=stoptime />
</form>
<?php
if(isset($_POST['time']))
if($_POST['time'])
echo "<marquee direction=right behavior=alternate scrolldelay=500 scrollamount=30><div id='txt'></div></marquee>";
?>
</body>
</html>

EDIT: without the marquee tags, the script works

i give u code to display time make change according u need of if you want that i give u whole code then send ur file on which i can make change

i made it work now :) thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.