View Full Version : HTML question
chrisbaker4937
Apr 8, 2003, 08:54 AM
Hello,
I would like my website to display the date automatically (without me having to update the page each day) , can anyone let me have HTML to do this ?
I can understand that putting the time on the page could be more complicated allowing for time zones but hopefully the date is a bit easier.
Thanks ?
coreybryant
Apr 8, 2003, 12:26 PM
Check out this site for some scripts & examples:
http://www.scriptsearch.com/JavaScript/Tips_and_Tutorials/Date_and_Time/
Corey
chrisbaker4937
Apr 9, 2003, 07:31 AM
Thanks for the info - I checked the site and a couple of the links are no longer valid and the other one had loads of html that I could not get to work...
Any other help would be gratefully received. :-/
coreybryant
Apr 9, 2003, 08:07 AM
Afte looking at it again, this is what I came up with - only for the date. Place this somewhere before the </head>:
<script language="JavaScript">
<!--
//Get Date
Var months=new Array(13);
Months[1]="January";
Months[2]="February";
Months[3]="March";
Months[4]="April";
Months[5]="May";
Months[6]="June";
Months[7]="July";
Months[8]="August";
Months[9]="September";
Months[10]="October";
Months[11]="November";
Months[12]="December";
Var time=new Date();
Var lmonth=months[time.getMonth() + 1];
Var date=time.getDate();
Var year=time.getYear();
If (year < 2000)
Year = year + 1900;
//-->
</script>
And then place this script wherever you want the date to appear:
<script language="javascript">
Document.write(lmonth + " " + date + ", " + year);
</script>
Corey
chrisbaker4937
Apr 10, 2003, 03:44 AM
;)
Thanks for your help - all OK now and used on my site.
Regards