Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


itiel shwartz
itiel shwartz
2,440 Points

JS problem

hi, i just started using js and i try adding date to my web, i used this code : __extrnal 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("<font color='fffff' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+ "</b></font>")

and imported it using (in my html website): <p><script src="js/datescript.js" id="sc"></p> now i want the text to look like p in my css, how do i do it?

thank you, itiel.

1 Answer

I'm not sure if your code runs, but to answer the question about getting a string to be styled as a paragraph element you could do the following:

<p id="date_paragraph"></p>
document.getElementById('date_paragraph').innerHTML = 'your string';