Display the live time.

Hosmer23 Hosmer23 is offline Offline Apr 18th, 2007, 12:01 am |
-1
Diplays the exact current time and date
Quick reply to this message  
HTML and CSS Syntax
  1. <body onLoad="goforit()">
  2.  
  3.  
  4.  
  5. <script>
  6.  
  7. /*
  8. Live Date Script-
  9. © Dynamic Drive (www.dynamicdrive.com)
  10. For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use,
  11. visit http://www.dynamicdrive.com
  12. */
  13.  
  14.  
  15. var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
  16. var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
  17.  
  18. function getthedate(){
  19. var mydate=new Date()
  20. var year=mydate.getYear()
  21. if (year < 1000)
  22. year+=1900
  23. var day=mydate.getDay()
  24. var month=mydate.getMonth()
  25. var daym=mydate.getDate()
  26. if (daym<10)
  27. daym="0"+daym
  28. var hours=mydate.getHours()
  29. var minutes=mydate.getMinutes()
  30. var seconds=mydate.getSeconds()
  31. var dn="AM"
  32. if (hours>=12)
  33. dn="PM"
  34. if (hours>12){
  35. hours=hours-12
  36. }
  37. if (hours==0)
  38. hours=12
  39. if (minutes<=9)
  40. minutes="0"+minutes
  41. if (seconds<=9)
  42. seconds="0"+seconds
  43. //change font size here
  44. var cdate="<small> <font color='000000' face='Arial'> <b> "+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
  45. +"</b> </font> </small> "
  46. if (document.all)
  47. document.all.clock.innerHTML=cdate
  48. else if (document.getElementById)
  49. document.getElementById("clock").innerHTML=cdate
  50. else
  51. document.write(cdate)
  52. }
  53. if (!document.all&&!document.getElementById)
  54. getthedate()
  55. function goforit(){
  56. if (document.all||document.getElementById)
  57. setInterval("getthedate()",1000)
  58. }
  59.  
  60. </script>
  61. <span id="clock"></span>
0
uringinteristi uringinteristi is offline Offline | Dec 28th, 2008
thank you
 
 

Message:


Similar Threads
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC