Tutorials > HTML Code Bank Add Today's Date
HTML Code to add today's date to your homepage
To add a today's date to your homepage:
1) Login, click Website, and click Homepage.
2) Locate a spot on the page where you wish to place today's date. Click into the nearby drop down menu that says, "Select New Section to Display."
3) Select HTML (located underneath TEXT TOOLS) and click the "Add" button.
4) Paste the code below into both the sections for logged in and not logged in and remember to Save Changes.
Here's the code:
<script LANGUAGE="JavaScript">
<!--
function MakeArray(n) {
this.length = n
return this
}
monthNames = new MakeArray(12)
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"
dayNames = new MakeArray(7)
dayNames[1] = "Sun."
dayNames[2] = "Mon."
dayNames[3] = "Tues."
dayNames[4] = "Wed."
dayNames[5] = "Thurs."
dayNames[6] = "Fri."
dayNames[7] = "Sat."
function customDateString() {
currentDate = new Date()
var theDay = dayNames[currentDate.getDay() + 1]
var theMonth = monthNames[currentDate.getMonth() + 1]
msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
if (msie4) {
var theYear = currentDate.getYear()
}
else {
var theYear = currentDate.getYear() +1900
}
return theDay + " " + theMonth + " " + currentDate.getDate() + ", " + theYear
}
//-->
</script>
<center>
<h5><span style="color:white;">
<script LANGUAGE="JavaScript">
document.write(customDateString())
</script></span>
</h5>
</center>
| 
|