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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:07:18+00:00 2026-05-11T06:07:18+00:00

I think its possible but i cant come up with the right algorithm for

  • 0

I think its possible but i cant come up with the right algorithm for it.

What i wanted to do was:

If today is monday feb 2 2009, how would i know the date of last week’s tuesday? Using that same code 2 days after, i would find the same date of last week’s tuesday with the current date being wednesday, feb 4 2009.

  • 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. 2026-05-11T06:07:18+00:00Added an answer on May 11, 2026 at 6:07 am

    I know there is an accepted answer already, but imho it does not meet the second requirement that was asked for. In the above case, strtotime would yield yesterday if used on a wednesday. So, just to be exact you would still need to check for this:

    $tuesday = strtotime('last Tuesday'); // check if we need to go back in time one more week $tuesday = date('W', $tuesday)==date('W') ? $tuesday-7*86400 : $tuesday; 

    As davil pointed out in his comment, this was kind of a quick-shot of mine. The above calculation will be off by one once a year due to daylight saving time. The good-enough solution would be:

    $tuesday = date('W', $tuesday)==date('W') ? $tuesday-7*86400+7200 : $tuesday; 

    If you need the time to be 0:00h, you’ll need some extra effort of course.

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

Sidebar

Related Questions

Based on a simple test I ran, I don't think it's possible to put
Its possible I am just really really thick. However, looking over the SDK for
This is the URL. http://www.tumblr.com/ I think that its based on prototype, and is
The PHP documentation can be found here , but I think it's rather lacking.
I think it's better to release the version of the software which your developers
Currently in our enterprise we have a situation that i think it's not very
I'm seeing an ambiguous error in Firebug. I don't think it's particularly related to
I'm using git for a PHP project, I think it's really handy. There is
I think most of us agree that it's a good idea to use a
Sometimes it's difficult to describe some of the things that us programmers may think

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.