User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 374,512 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,927 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 HTML and CSS advertiser: Lunarpages Web Hosting
Apr 17th, 2007
Views: 6,110
Diplays the exact current time and date
html Syntax | 5 stars
  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>
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 2:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC