Add the current date to your web site
If you are new to web design you may have noticed that some web sites always display the current date, and wondered how this is done. It is a very simple thing to do, and you don’t need to update your site everyday. All you need to do is add some JavaScript [Define] to your web site.
Easy way to add the date
To add the date open the program you edit your web pages i.e. Dreamweaver, Frontpage, it doesn’t matter which one it is as long as you can edit the HTML code [Define] manually. Now you need to view the html code of the site. Each pprogram is different; you may need to look in the help menu of the program to find out how to look at the HTML code.
<SCRIPT LANGUAGE="Javascript" class="timetext">
var now = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
var months = new Array('January','February','March','April',
'May','June','July','August','September',
'October','November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function y2k(number){return (number < 1000) ? number + 1900 : number;}
today = days[now.getDay()] + " " +
date + " " +
months[now.getMonth()] + ", " +
(y2k(now.getYear())) ;
document.write("" +today+ ".");
</SCRIPT>
This bit of code will display the correct date no matter where your web site is being viewed in the world.
Easy way to add the date
To add the date open the program you edit your web pages i.e. Dreamweaver, Frontpage, it doesn’t matter which one it is as long as you can edit the HTML code [Define] manually. Now you need to view the html code of the site. Each pprogram is different; you may need to look in the help menu of the program to find out how to look at the HTML code.
When viewing the HTML code, copy and paste the below code in to the web page. Place it in the area you wish to display the current date.
<SCRIPT LANGUAGE="Javascript" class="timetext">
var now = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
var months = new Array('January','February','March','April',
'May','June','July','August','September',
'October','November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function y2k(number){return (number < 1000) ? number + 1900 : number;}
today = days[now.getDay()] + " " +
date + " " +
months[now.getMonth()] + ", " +
(y2k(now.getYear())) ;
document.write("" +today+ ".");
</SCRIPT>
This bit of code will display the correct date no matter where your web site is being viewed in the world.
More web design tips
5 Comments:
Thanks for the script
By Tifosi, at 8:40 pm
Thanks alot. This realy helps.
By Joe, at 11:24 pm
I have been searching for this forever. Thanks so much!
By grafixgrrrl, at 12:57 pm
Nice one, but how can I change the font?
By Editor, at 7:18 pm
Thumbs up mate. Quite impressive. Well appreciated.
By Andie Femi Moyan , at 11:47 am
Post a Comment
<< Home