943,926 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
May 21st, 2009
0

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

You may place it anywhere inside the header section of your page.

Just make sure it doesn't interfere with your <script></script> block.
Featured Poster
Reputation Points: 114
Solved Threads: 138
Posting Shark
essential is offline Offline
973 posts
since Aug 2008
May 21st, 2009
0

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

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:



html Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starengineer is offline Offline
9 posts
since May 2009
May 21st, 2009
0

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

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
javascript Syntax (Toggle Plain Text)
  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.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
May 23rd, 2009
0

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

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starengineer is offline Offline
9 posts
since May 2009
May 23rd, 2009
0

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

<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.
Reputation Points: 12
Solved Threads: 34
Posting Whiz
sreein1986 is offline Offline
306 posts
since May 2008
May 23rd, 2009
0

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

sreein1986 this did solve my problem
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starengineer is offline Offline
9 posts
since May 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Site Layout and Usability Forum Timeline: About CMS and a website
Next Thread in Site Layout and Usability Forum Timeline: Great Place for free templates and other resources.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC