User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,662 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,853 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 561 | Replies: 9 | Solved
Reply
Join Date: Mar 2008
Posts: 10
Reputation: soultrav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
soultrav soultrav is offline Offline
Newbie Poster

display time

  #1  
Mar 29th, 2008
If i have, for example, a marquee that displays time when i push a button,like this:
  1. if($_POST['time'])
  2. 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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Location: Gurgaon India
Posts: 64
Reputation: nikesh.yadav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Junior Poster in Training

Re: display time

  #2  
Mar 29th, 2008
you go through javascript to make the change in time
Reply With Quote  
Join Date: Mar 2008
Posts: 10
Reputation: soultrav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
soultrav soultrav is offline Offline
Newbie Poster

Re: display time

  #3  
Mar 29th, 2008
i don't know too much js so...how can i do that?
Reply With Quote  
Join Date: Feb 2008
Location: Gurgaon India
Posts: 64
Reputation: nikesh.yadav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Junior Poster in Training

Re: display time

  #4  
Mar 29th, 2008
ok wait
Reply With Quote  
Join Date: Dec 2007
Posts: 52
Reputation: kishou is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kishou kishou is offline Offline
Junior Poster in Training

Re: display time

  #5  
Mar 29th, 2008
Reply With Quote  
Join Date: Feb 2008
Location: Gurgaon India
Posts: 64
Reputation: nikesh.yadav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Junior Poster in Training

Re: display time

  #6  
Mar 29th, 2008
<!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>
Last edited by peter_budo : Mar 30th, 2008 at 5:21 am. Reason: [icode] is for one line of code, [code] is for multiple lines
Reply With Quote  
Join Date: Feb 2008
Location: Gurgaon India
Posts: 64
Reputation: nikesh.yadav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Junior Poster in Training

Re: display time

  #7  
Mar 29th, 2008
i think you find the answer
Reply With Quote  
Join Date: Mar 2008
Posts: 10
Reputation: soultrav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
soultrav soultrav is offline Offline
Newbie Poster

Re: display time

  #8  
Mar 29th, 2008
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?
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function startTime()
  5. {
  6. var today=new Date();
  7. var h=today.getHours();
  8. var m=today.getMinutes();
  9. var s=today.getSeconds();
  10. // add a zero in front of numbers<10
  11. m=checkTime(m);
  12. s=checkTime(s);
  13. document.getElementById('txt').innerHTML=h+":"+m+":"+s;
  14. t=setTimeout('startTime()',500);
  15. }
  16.  
  17. function checkTime(i)
  18. {
  19. if (i<10)
  20. {
  21. i="0" + i;
  22. }
  23. return i;
  24. }
  25. </script>
  26. </head>
  27. <body onload="startTime()">
  28. <form method=post action=d.php>
  29. <input type=submit value="Push for time!" name=time />
  30. &nbsp&nbsp&nbsp
  31. <input type=submit value="Push to stop time!" name=stoptime />
  32. </form>
  33. <?php
  34. if(isset($_POST['time']))
  35. if($_POST['time'])
  36. echo "<marquee direction=right behavior=alternate scrolldelay=500 scrollamount=30><div id='txt'></div></marquee>";
  37. ?>
  38. </body>
  39. </html>

EDIT: without the marquee tags, the script works
Last edited by soultrav : Mar 29th, 2008 at 6:41 am.
Reply With Quote  
Join Date: Feb 2008
Location: Gurgaon India
Posts: 64
Reputation: nikesh.yadav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Junior Poster in Training

Re: display time

  #9  
Mar 29th, 2008
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
Reply With Quote  
Join Date: Mar 2008
Posts: 10
Reputation: soultrav is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
soultrav soultrav is offline Offline
Newbie Poster

Re: display time

  #10  
Mar 30th, 2008
i made it work now thanks again
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:47 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC