vForums Support > Programming & Coding :: Database of Codes/Hacks/Mods :: > Time in Menu Bar

Time in Menu Bar - Posted By Danny (schnooble) on 30th Dec 07 at 3:01am
Global Header

Preview

No need to edit {Smile}

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*Time to the left of menu butons by Danny*/
  4.  
  5. function startTime(){
  6. var today=new Date()
  7. var h=today.getHours()
  8. var m=today.getMinutes()
  9. var s=today.getSeconds()
  10. m=checkTime(m)
  11. s=checkTime(s)
  12. document.getElementById('time').innerHTML=h+":"+m+":"+s
  13. t=setTimeout('startTime()',500)}
  14. function checkTime(i){
  15. if (i<10) {
  16. i="0" + i}
  17. return i}
  18.  
  19. var menu = document.getElementById('welcome_table').getElementsByTagName('td')[2];
  20.  
  21. menu.innerHTML = '<span style="float:right;" id="time"></span>' + menu.innerHTML;
  22.  
  23. window.onload = startTime();
  24.  
  25. //-->
  26. </script>
 

Re: Time in Menu Bar - Posted By Michael (wrighty) on 30th Dec 07 at 3:02am
have you tested this?

Re: Time in Menu Bar - Posted By Danny (schnooble) on 30th Dec 07 at 3:06am
yeah il add a preview {Smile}

Re: Time in Menu Bar - Posted By Michael (wrighty) on 30th Dec 07 at 3:09am
looks good! {Smile}

Re: Time in Menu Bar - Posted By Danny (schnooble) on 30th Dec 07 at 3:09am
thanks man {Smile}

Re: Time in Menu Bar - Posted By Marc (cr0w) on 30th Dec 07 at 3:42am
Just so you know, the time shows up to the right of the menu buttons, not the left. {Wink}

Re: Time in Menu Bar - Posted By Michael (wrighty) on 30th Dec 07 at 3:45am
lol it's coded to go right, but the Copyright says left! {Tongue Out}

Re: Time in Menu Bar - Posted By Marc (cr0w) on 30th Dec 07 at 3:46am
 
lol it's coded to go right, but the Copyright says left! {Tongue Out}


That's pretty much what I just said. {Wink}

Re: Time in Menu Bar - Posted By Michael (wrighty) on 30th Dec 07 at 3:47am
and I was just reiterating it cause it was funny! >.>

Re: Time in Menu Bar - Posted By Marc (cr0w) on 30th Dec 07 at 3:48am
 
and I was just reiterating it cause it was funny! >.>


Ahh, that works. {Tongue Out}

Re: Time in Menu Bar - Posted By Danny (schnooble) on 30th Dec 07 at 3:52am
oops I meant to say right {Tongue Out} I even put float:right; in the code {Tongue Out}

Re: Time in Menu Bar - Posted By Marc (cr0w) on 30th Dec 07 at 4:16am
 
oops I meant to say right {Tongue Out} I even put float:right; in the code {Tongue Out}


Haha, no problem. {Smile}

Re: Time in Menu Bar - Posted By Samus (samus) on 30th Dec 07 at 4:52am
menu.innerHTML = '<span style="float:right;" id="time"></span>'+menu.innerHTML+'';

It needs only be;

menu.innerHTML = '<span style="float:right;" id="time"></span>'+menu.innerHTML;

Because, you can't actually add nothing to the end of something. {Tongue Out}

Re: Time in Menu Bar - Posted By Danny (schnooble) on 30th Dec 07 at 7:11pm
just changed it {Smile}

Re: Time in Menu Bar - Posted By ManGoneMad (mgm) on 30th Dec 07 at 11:59pm
Nice script! {Smile}
Is there any way to have show normal 12 hour time, as opposed to military time?

Re: Time in Menu Bar - Posted By Michael (wrighty) on 31st Dec 07 at 12:00am
Post a request to have it changed! {Wink}

it'd be sooo much easier! {Tongue Out}

Re: Time in Menu Bar - Posted By ManGoneMad (mgm) on 31st Dec 07 at 12:10am
Ok, Thanks will do!

Re: Time in Menu Bar - Posted By Danny (schnooble) on 31st Dec 07 at 12:19am
you mean so after 12 o clock it goes back to 1 each time ?

Re: Time in Menu Bar - Posted By Michael (wrighty) on 31st Dec 07 at 12:20am
Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*Time to the left of menu butons by Danny*/
  4.  
  5. function startTime(){
  6. var today=new Date()
  7. var h=today.getHours()
  8. var m=today.getMinutes()
  9. var s=today.getSeconds()
  10. m=checkTime(m)
  11. s=checkTime(s)
  12. e = 'am'
  13. if(h=="12"){
  14. e = "pm";
  15. }
  16. if(h=='0'){
  17. h="12";
  18. }else if(h>12){
  19. h=parseInt(h - 12);
  20. e = "pm"
  21. }
  22.  
  23.  
  24. document.getElementById('time').innerHTML=h+":"+m+":"+s + " " + e
  25. t=setTimeout('startTime()',999)}
  26. function checkTime(i){
  27. if (i<10) {
  28. i="0" + i}
  29. return i}
  30.  
  31. var menu = document.getElementById('welcome_table').getElementsByTagName('td')[2];
  32.  
  33. menu.innerHTML = '<span style="float:right;" id="time"></span>' + menu.innerHTML;
  34.  
  35. window.onload = startTime();
  36.  
  37. //-->
  38. </script>
 


{Smile} Editted, hope you don't mind Danny... Feel free to clean up the code! {Tongue Out}

Re: Time in Menu Bar - Posted By ajay (ajay) on 20th Feb 08 at 3:58pm
Thanks for the code!