Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Stamp formatting 2

Status
Not open for further replies.
May 20, 2010
18
US
I need to change the font size on a date script that I have on my page.

I am using dreamweaver cs5. What is a no frills way to go about this, as I am not a code-warrior.

Or alternatively, Is there an easier way to get a simple dynamic date stamp on a web page.
The page is made in html and hosted off IIS.

Thank You


This is the script that I am using.

<script>
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 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")
document.write("<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>")

</script>

TekSupporter
MCP, A+, CNA
 
I would change your script to output modern CSS style properties rather than font and color tags:

Code:
document.write("<span style='font-family:Arial; color:#000000; font-weight:bold; [red]font-size:24px;[/red]'>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</span>");




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Or even better, just assign a class to the output element and style it in your stylesheet. So that when you change your mind on how it should look, you can quickly change it without venturing back into JS.
Code:
document.write("<span class='date'>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</span>");

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Thank you all,

I will try those options and post the results.





TekSupporter
MCP, A+, CNA
 
Thank you both for your help. I went with vacunita's suggestion. However, in the long run, assigning a class would save me time/headache whenit comes to changes.

TekSupporter
MCP, A+, CNA
 
When we get a useful reply in these forums we usually acknowledge the reply by clicking on the link "Thank helpers handle
for this valuable post!" that you will find at the bottom of the posts that you found useful.

If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top