Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3610230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:43:34+00:00 2026-05-18T21:43:34+00:00

A while ago I needed a script to update some content every week, and

  • 0

A while ago I needed a script to update some content every week, and my question was answered in this forum.

—

Now, and I’m not a jQuery pro like you :), but the “problem” I have is that today (the moment of this post) it’s week #52 but the script wasn’t working, it wasn’t showing the content for week #52, so I changed my HTML to week #53, and it worked.

The “problem” is that there’s no week #53, so I’m afraid I’m going to have to change my HTML to continue counting for week #54, #56, #57 and so on, when those weeks don’t exist.

Here’s an extract of the HTML (the structure repeats over the weeks, content changes of course):

<div class="quotes-container quote-53">
 <div class="quote">Quote here...</div>
 <div class="author">&mdash; Author </div>
</div>

Script:

<script type="text/javascript">
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}

jQuery(function(){  
 var today = new Date();
 var weekno = today.getWeek();
 jQuery('#quotes-wrapper').load('/common/testimonials.html div.quote-'+weekno);
});
</script>

Any idea what’s going on?

Thanks a lot for any help on this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:43:35+00:00Added an answer on May 18, 2026 at 9:43 pm

    EDIT: The script you’re using considers a “week” to be Sunday – Saturday. Since a year doesn’t always start on a Sunday, it considers the first partial week to be week 1.

    If you simply want 7 say periods since the first of the year, use the script below. If you want it based on Sunday, then the script you’re using would be correct.


    There is a week #53. It’s just not a full week.

    But we are in week 52. I’m guessing the current script doesn’t account for leap years.

    Instead you can calculate the day of this year, and divide that by 7.

    Example: http://jsfiddle.net/etTS2/2/

    <script type="text/javascript">
    
        Date.prototype.getWeek = function() {
          var onejan = new Date(this.getFullYear(),0,1);
          var today = new Date(this.getFullYear(),this.getMonth(),this.getDate());
          var dayOfYear = ((today - onejan +1)/86400000);
          return Math.ceil(dayOfYear/7)
        };
    
    
        jQuery(function(){  
         var today = new Date();
         var weekno = today.getWeek();
         jQuery('#quotes-wrapper').load('/common/testimonials.html div.quote-'+weekno);
        });
    
    </script>
    

    You’ll still get a result of 53 on the last day of the year (or last two days in a leap year).

    EDIT: Fixed a offset of 1 on the dayOfYear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked this question a while ago. I now know it is a Bad
I raised a question about this a while ago but I'm still having an
A while ago, I came across some code that marked a data member of
A while ago, I asked a question about $ , and got useful answers
A while ago another question referred to the (possibly urban tale) statistic that ...
A while ago I was trying to figure out a way of doing this
I asked a question a while ago about which local DB was right for
I have an application that I created a while ago for some unknown portable
I read this somewhere a while ago but cant seem to find it. I
A while ago, I started on a project where I designed a html-esque XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.