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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:16:56+00:00 2026-06-09T10:16:56+00:00

I need to find date x such that it is n working days prior

  • 0

I need to find date x such that it is n working days prior to date y.

I could use something like date("Y-m-d",$def_date." -5 days");, but in that case it wont take into consideration the weekend or off-date. Let’s assume my working days would be Monday to Saturday, any idea how I can accomplish 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-06-09T10:16:58+00:00Added an answer on June 9, 2026 at 10:16 am

    Thanks for the help guys, but to solve this particular problem I wrote a simple code:

        $sh_padding = 5; //No of working days to count backwards 
        $temp_sh_padding = 1; //A temporary holder
        $end_stamp = strtotime(date("Y-m-d", strtotime($date_format)) . " -1 day"); //The date(timestamp) from which to count backwards
        $start_stamp = $end_stamp; //start from same as end day
        while($temp_sh_padding<$sh_padding)
        {
            $sh_day = date('w',$start_stamp);
            if($sh_day==0){ //Skip if sunday
            }
            else
            {
                $temp_sh_padding++;
            }
            $start_stamp = strtotime(date("Y-m-d",$start_stamp)." -1 day");
        }
        $sh_st_dte = date("Y-m-d",$start_stamp); //The required start day
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a GWT app that needs something like a CellTable to display and
I need to find a date after a certain number of weeks. For example,
I have start date and end date. I need to find out the day
In the following table, I need to find out the login date and how
I need to find a silence in a mp3 file. Simple as that. For
I have the following text: abcabcabcabc<2007-01-12><name1><2007-01-12>abcabcabcabc<name2><2007-01-11>abcabcabcabc<name3><2007-02-12>abcabcabcabc<name4>abcabcabcabc<2007-03-12><name5><date>abcabcabcabc<name6> I need to use regular expressions in order
I need to find a value in a file that has an id (say
I have unstructured string. From this I need to find the date. Example: [expected
How do you actually perform datetime operations such as adding date, finding difference, find
I need to import data from excel,And the I decided to use PHPExcel,But when

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.