Today in JavaScript
Dateline: 04/23/99
Everybody wants their web pages to look new. This is especially true for sites
that claim to be "on top of things;" sites that are in fact about news.
Nobody takes the time to go buy yesterday's newspaper, so why shouldn't your site
always be about "today?"
Today, this web site is about:
If your web page displays the current day (today is
), it
feels a little more up-to-date. It's easy to display the current day using
JavaScript.
JavaScript has a built-in method called getDay(), that returns a number
between 0 and 6 signifying what day of the week it is. Take the following code, for
example:
theDate = new Date ();
today = theDate.getDay();
today will contain a 0 on Sunday, a 1 on Monday, a 2 on Tuesday, and so
on. It is simple from this point to make an array of day names and display them,
load an appropriate graphic, display a different link each day, whatever you can come up
with. Here's an array of day names:
whatDay = new Array();
whatDay[0] = "Sunday";
whatDay[1] = "Monday";
whatDay[2] = "Tuesday";
whatDay[3] = "Wednesday";
whatDay[4] = "Thursday";
whatDay[5] = "Friday";
whatDay[6] = "Saturday";
Which can be translated into text:
document.write("Today is " + whatDay[today] + " and the weather is
nice.");
Or an image:
document.write('<img src=/old?u=http%3A%2F%2Fjavascript.about.com%2Fcompute%2Fjavascript%2Flibrary%2Fweekly%2F%26quot&y=1999' + whatDay[today] + '.gif">');
Related Links:
Image of the Day
from The Complete Webmaster
Day of the Week Image Displayer
from Website Abstraction
Scripts - Time
Tutorials - Time
Previous Features
|
Sponsored Links |
Netsetter - the free download accelerator
Download and install the Netsetter software and you can double your internet speed and have a chance to win a BMWZ3 Sports Car!
http://www.commission-junction.com/ (Listing fee: $0.33)
|
Find Practically Anything on Earth at eBay!
eBay - the world's largest online trading site where people buy, sell or trade practically anything on earth. Over 4 million items available in over 4,000 categories including javascript
http://cgi.ebay.com/ (Listing fee: $0.30)
|
Increase your download speeds for FREE!
Netsetter will optimize your web browser and internet connection settings to increase your internet speed by up to 100%.
http://www.commission-junction.com/ (Listing fee: $0.23)
|
Web Design for Search Engines - Web Position Gold
Web design & promotion software for higher search engine ranking. WebPosition Gold optimizes, submits, & tracks your site for top results. FREE Trial download.
http://www.web-gold.net/ (Listing fee: $0.22)
|
Computer Training Videos & CD ROMs
Planetlearn.com provides over 2000 self paced computer training programs available on video, cd rom, and online.
http://www.planetlearn.com/ (Listing fee: $0.21)
|
|
|
|
 |