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

  • Home
  • SEARCH
  • 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 8953201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:03:05+00:00 2026-06-15T14:03:05+00:00

Can someone help me figuring out how to get if a current week is

  • 0

Can someone help me figuring out how to get if a current week is inside an occurrence .

I have the following vars : start_date , end_date , current_date week_occurrence .

and i have a function that return the # of occurrence

// will return the number of weeks between start - end
function get_weeks_count($start , $end) {
       return floor(abs(strtotime($start) - strtotime($end)) / 604800);    
    }

now i have to know if a current date is a valid date .

I have an entry with occurrence = every N weeks . How to know that N is valid .

Less abstract : If we are in December and the occurrence is every 3 weeks , start_date is 1st and end_date is 30 December)

It will return :

 TRUE  for 1st week

 FALSE for the second week

 FALSE for the third week

 TRUE  for the last week
  • 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-15T14:03:06+00:00Added an answer on June 15, 2026 at 2:03 pm

    Here’s how I would approach the problem – this applies for an occurrence every $n weeks.

    $n = $week_occurrence;
    $occurrence = false;
    
    // To begin, get the number of weeks between the start and current dates.
    $weeks = get_weeks_count($start_date , $current_date); // Using the function you already have
    
    // Now check if $weeks == 0
    if ($weeks == 0) {
        $occurrence = true;
    
    // If not, check if $weeks is divisible by $n without any remainder
    } else if ($weeks % $n == 0) {
        $occurrence = true;
    }
    

    If $occurrence is still false then the current week does not fall within the the correct occurrence, if it’s true then the week does fall within the scope.

    Effectively all we’re doing here is checking that the current number of weeks since the start date is either equal to zero (we’re still in the first week) or is divisible by the ocurrence without a remainder.

    I hope this helps.

    P.S. I’ve only answered the specific question that you asked. However, if you would like to know more about how this premiss could be used for scheduling etc., then feel free to ask and I’ll expand on my answer accordingly

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

Sidebar

Related Questions

Can someone help me figuring out why the following jQuery code doesn't work? I
Would like to see if someone can help me on figuring out how to
I'm having much trouble figuring this out, so maybe someone can help me. This
Can someone help by showing me how to sort a LINQ expression. I have
Can someone help me with creating functions for the following processes? I want to
Can someone help me find the problem? I have MainActivity, that when I go
I'm having a bit of trouble figuring this out so if you can help
I hope someone can help me with this. I am having some trouble figuring
Need help in figuring out a tool which can convert a flash (.swf) chart
Can someone help me out please, as google is not providing the answers. I've

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.