trying to place live date & Time in web page

Please support our Site Layout and Usability advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: trying to place live date & Time in web page

 
0
  #11
May 21st, 2009
You may place it anywhere inside the header section of your page.

Just make sure it doesn't interfere with your <script></script> block.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 9
Reputation: starengineer is an unknown quantity at this point 
Solved Threads: 0
starengineer's Avatar
starengineer starengineer is offline Offline
Newbie Poster

Re: trying to place live date & Time in web page

 
0
  #12
May 21st, 2009
Ok, I have two questions. based on the codes below where do I disable or turn on/off the time display.

Question (2) there is a line that say //change font size here
what is the format or javascript language to change the font size please give an example:



  1. <html>
  2. <head>
  3. <script type='text/javascript'>
  4. <!--
  5. /*
  6. Live Date Script-
  7. © Dynamic Drive ([url]www.dynamicdrive.com[/url])
  8. For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use,
  9. visit [url]http://www.dynamicdrive.com[/url]
  10. */
  11. var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
  12. var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
  13. function getthedate(){
  14. var mydate=new Date()
  15. var year=mydate.getYear()
  16. if (year < 1000)
  17. year+=1900
  18. var day=mydate.getDay()
  19. var month=mydate.getMonth()
  20. var daym=mydate.getDate()
  21. if (daym<10)
  22. daym="0"+daym
  23. var hours=mydate.getHours()
  24. var minutes=mydate.getMinutes()
  25. var seconds=mydate.getSeconds()
  26. var dn="AM"
  27. if (hours>
  28. =12) {dn="PM"}
  29. if (hours>12){ hours=hours-12 }
  30. if (hours==0) { hours=12 }
  31. if (minutes<=9) { minutes="0"+minutes }
  32. if (seconds<=9) { seconds="0"+seconds }
  33. //change font size here
  34. var cdate="<small> <font color='000000' face='Arial'> <b> "+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
  35. +"</b> </font> </small> "
  36. if (document.all)
  37. document.all.clock.innerHTML=cdate
  38. else if (document.getElementById)
  39. document.getElementById("clock").innerHTML=cdate
  40. else
  41. document.write(cdate)
  42. }
  43. if (!document.all&&!document.getElementById)
  44. getthedate()
  45. function goforit(){
  46. if (document.all||document.getElementById)
  47. setInterval("getthedate()",1000)
  48. }
  49. -->
  50. </script>
  51. </head>
  52. <body onLoad="goforit()">
  53. <span id="clock"></span><!-- the span at left goes exactly where you want the clock -->
  54. </body>
  55. </html>
Last edited by peter_budo; May 24th, 2009 at 3:57 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
StarDustEngineer
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,332
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 162
almostbob's Avatar
almostbob almostbob is online now Online
Nearly a Posting Virtuoso

Re: trying to place live date & Time in web page

 
0
  #13
May 21st, 2009
an old, form of html gives font sizes as <small><large> etc
directly below the //change font size you will see the code includes <small>some text </small> to set font size.
The script is old, and though it works it doesnt take advantage of recent developments.
the line
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"

is the one that contains the strings for what is displayed

-copy it -comment it
and you can mess with the copy as much as you need to get the display as you wish
  1. //commented out
  2. //var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn +"</b></font></small>"
  3. var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>"
and still retain a backup of all the fields
Last edited by almostbob; May 21st, 2009 at 9:13 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 9
Reputation: starengineer is an unknown quantity at this point 
Solved Threads: 0
starengineer's Avatar
starengineer starengineer is offline Offline
Newbie Poster

Re: trying to place live date & Time in web page

 
0
  #14
May 23rd, 2009
almostbob how can I take advantage of recent developments.

would it look something like this

var cdate="<style="font-size:150% font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>"

here is the original

var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>"
Last edited by peter_budo; May 24th, 2009 at 3:58 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
StarDustEngineer
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 302
Reputation: sreein1986 is an unknown quantity at this point 
Solved Threads: 33
sreein1986's Avatar
sreein1986 sreein1986 is offline Offline
Posting Whiz

Re: trying to place live date & Time in web page

 
0
  #15
May 23rd, 2009
<body onLoad="goforit()"><script>
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
 
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='0000FF' face='Tahoma'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}
 
</script>
<span id="clock"></span>
</body>
Last edited by sreein1986; May 23rd, 2009 at 3:56 am.
Thanx,
Shiriyal

http://shiriyal.blogspot.com/
if you problem solved add me as a reputation and mark it mark as solved
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 9
Reputation: starengineer is an unknown quantity at this point 
Solved Threads: 0
starengineer's Avatar
starengineer starengineer is offline Offline
Newbie Poster

Re: trying to place live date & Time in web page

 
0
  #16
May 23rd, 2009
sreein1986 this did solve my problem
StarDustEngineer
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Site Layout and Usability Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC