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 8137819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:17:12+00:00 2026-06-06T11:17:12+00:00

So I just have posted a question about this code (which was answered): $(document).ready(Main);

  • 0

So I just have posted a question about this code (which was answered):

$(document).ready(Main); 

function Main() { 
    ConfigDate();         
} 


function ConfigDate() { 
    var currentTime = new Date(); 
    var dayofWeek = currentTime.getDay(); 

    var daysSinceThursday = (dayofWeek + 3) % 7 
    var lastThursday = new Date(currentTime.getDate() - daysSinceThursday); 
    var dd = lastThursday.getDate(); 

    var mm = lastThursday.getMonth() + 1; 
    var yyyy = lastThursday.getFullYear(); 

    $("#last_thursday").text(yyyy + " / " + mm + " / " + dd); 
} 

The problem now is that the date that appears in my cell is 1969 / 12 / 31 (which isn’t even a thursday).

Did I do something wrong while calculating last thursday date?

  • 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-06-06T11:17:14+00:00Added an answer on June 6, 2026 at 11:17 am

    You’re trying to set a Date based only on the day of the month of the last Thursday. Try something like this:

    var daysSinceThursday = (dayofWeek + 3) % 7;
    var lastThursday = new Date(currentTime.getTime());
    lastThursday.setDate(currentTime.getDate() - daysSinceThursday);
    var dd = lastThursday.getDate();
    
    var mm = lastThursday.getMonth() + 1; 
    var yyyy = lastThursday.getFullYear();
    

    http://jsfiddle.net/rAuRF/3/

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

Sidebar

Related Questions

I posted a question about this earlier, but I have more information now and
I have a question about this question . I posted a reply there but
I just have a quick question about how to get the length of a
Yesterday I posted this question about protecting files: Protecting the app sandbox As mentioned,
Stackoverflow is awesome! I just posted a question and it was answered by the
I recently posted this question about codes for a gift-card-like voucher that users can
I've posted about this last year because some university project and now I have
I just have a question regarding SimpleJSON's documentation. Is it implicit understood that functions
I just have a system crash and reinstall Ubuntu 11.10, and my code produces
I just have a question thats been pozzling my head all morning. I want

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.