How can I count the weeks on my web site with a counter script?


We are producing a 50 week program and we want to post automatically on our web site the specific week number of our program so that if anyone gets behind, they can keep up with the program.

How can we post the week number starting with week one and adding a number to that count each Sunday therefore counting the weeks on the web site with a counter script? Any suggestions/direction?

One Response to “How can I count the weeks on my web site with a counter script?”

  • Jace:

    I’m not sure exactly what you are looking for, but you can use javascript to get the number of weeks that have passed since a certain date. Personally, I would do it in server side code, but since you gave no indication of what technology you are using for you backend, here is some sample javascript…

    <script type="text/javascript">
    var startDate = new Date(2009, 7, 23); //August 23rd, 2009, Month is 0-11
    today = new Date();
    var one_week = 1000 * 60 * 60 * 24 * 7;
    var one_day = 1000 * 60 * 60 * 24;
    document.write(Math.floor((today.getTime() – startDate.getTime()) / (one_week)) + " weeks have gone by since the beginning of the program. \n");
    document.write(Math.floor((today.getTime() – startDate.getTime()) / (one_day)) + " days have gone by since the beginning of the program.");
    </script>

Leave a Reply