Once you create an HTML document it is static. Things like Javascript and server side scripts have made it so you can serve up dynamic content. This is just a short example on how to offer something dynamic on your site.
If you want to have today’s date on your page you can do something like this. Inside your <head> tag insert the following code.
<SCRIPT LANGUAGE=”Javascript”>
// Array of day names
var dayNames = new Array(”Sunday”,”Monday”,”Tuesday”,”Wednesday”,
“Thursday”,”Friday”,”Saturday”);
// Array of month Names
var monthNames = new Array(
“January”,”February”,”March”,”April”,”May”,”June”,”July”,
“August”,”September”,”October”,”November”,”December”);
var now = new Date();
todaysdate = dayNames[now.getDay()] + “, ” + monthNames[now.getMonth()] + ” ” + now.getDate() + “, ” + now.getFullYear();
</SCRIPT>
Then wherever you want the date in the <body> of your html just insert the following code.
<script>document.write(todaysdate);</script>
This will work on most browsers but keep in mind it is serving up the date of the computer it is being viewed on not the servers date.
Technorati Tags: basic, javascript, today's date