The Weekly Update

One of the more common features shared by most sites is the "What's New" page. This page can contain anything from news and press releases, to listings of new features that have been added to the site that week. But implementing a weekly "What's New" page can be a daunting task.

Depending on who and where you are, the week can start on Sunday or Monday. The first week of the year can be the first week which contains the 1st of January or the first Monday in January. And then there's the whole issue of reliability. Since this page will need to be updated weekly, you have to be able to rely on the human factor, i.e., can you trust someone to change the page and the links to it every week?

This article describes how you can manipulate the date object to figure out which week of the year a date falls in, and where the first week of the year is. (In this case, week 1 is defined as the week with the first Sunday in January.) It is important to note that, on occasion, the first few days of a particular year may fall into the last week of the previous year. Because of this, we will need 53 weekly pages instead of 52 (366 [365 days + 1 leap day] divided by 7 days [1 week] does not exactly equal 52 weeks).

There are two versions, the 'basic' version only allows selection of the 'current' week. The advanced selection allows you to select a particular date and its corresponding week.

The Basic Version The Advanced Version

Click here to test it out

Month: Day:
This example is done in javascript, there are many other ways to accomplish the same task with server side code and a database.
View the page source to see the code.

Back To Top
© 1998 - 2017 | My3C's

Version 7.2 | Advertise on this site