display time

Thread Solved

Join Date: Mar 2008
Posts: 17
Reputation: soultrav is an unknown quantity at this point 
Solved Threads: 0
soultrav soultrav is offline Offline
Newbie Poster

display time

 
0
  #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
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: display time

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

Re: display time

 
0
  #3
Mar 29th, 2008
i don't know too much js so...how can i do that?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: display time

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

Re: display time

 
0
  #5
Mar 29th, 2008
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: display time

 
0
  #6
Mar 29th, 2008
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>t</title>
  6. </head>
  7.  
  8. <body>
  9. <marquee direction=right behavior=alternate scrolldelay=500 scrollamount=30><div id="a"></div></marquee>
  10. </body>
  11. </html>
  12. <script type="text/javascript">
  13. function show()
  14. {
  15. var Digital=new Date()
  16. var hours=Digital.getHours()
  17. var minutes=Digital.getMinutes()
  18. var seconds=Digital.getSeconds()
  19. var dn="AM"
  20. if (hours>12)
  21. {
  22. dn="PM"
  23. hours=hours-12
  24. }
  25. if (hours==0)
  26. hours=12
  27.  
  28. if (minutes<=9)
  29. minutes="0"+minutes
  30. if (seconds<=9)
  31. seconds="0"+seconds
  32.  
  33. document.getElementById('a').innerHTML= ""+hours+":"+minutes+":"+seconds+" "+dn +""
  34. setTimeout("show()",1000)
  35. }
  36. show()
  37. </script>
Last edited by peter_budo; Mar 30th, 2008 at 6:21 am. Reason: [icode] is for one line of code, [code] is for multiple lines
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: display time

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

Re: display time

 
0
  #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 7:41 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: display time

 
0
  #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 Quick reply to this message  
Join Date: Mar 2008
Posts: 17
Reputation: soultrav is an unknown quantity at this point 
Solved Threads: 0
soultrav soultrav is offline Offline
Newbie Poster

Re: display time

 
0
  #10
Mar 30th, 2008
i made it work now thanks again
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC