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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:01:02+00:00 2026-05-27T22:01:02+00:00

How do I write a function in PHP that returns the date of delivery

  • 0

How do I write a function in PHP that returns the date of delivery without Saturdays, Sundays and holidays?

For example: for same product delivery is in 3 days for others in 5 days.

If I do a command today I will receive my command in 3 days without Saturdays, Sundays and holidays.

If I do my command now “29/12/2011” for a product “3j” I will receive your command at “4/1/2011”

In the database I have just how much the day for every type product is.

For example:

prod1: 3day  
prod2: 5day  
prod3: 7day   

I tried to do a function but failed.

  • 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-27T22:01:03+00:00Added an answer on May 27, 2026 at 10:01 pm

    This is a really complex subject that you can’t really fix with a simple function. You are talking about business days calculation strategies and they involve a lot of thinking.

    If you want to process only business days and not business hours, then it get slightly easier.

    The first step is to create an array of working days or an array of non working days. For example:

    //Build the days based of weekends
    $nonWorkingDays = array();
    foreach($iDate = 0; $iDate < 365; $iDate++){
        $date = strtotime('today +'.$iDate.' day');
        if(date('w', $date) == 0 || date('w', $date) == 6){
            $nonWorkingDays = date('Y-m-d', $date);
        }
    }
    
    //Add the holidays
    $nonWorkingDays[] = '2011-12-25';
    $nonWorkingDays[] = '2012-01-01';
    
    //Determine the date of delivery
    $daysToDelivery = 6;
    $deliveryDate = time();
    while($daysToDelivery > 0){
        $deliveryDate = time() + (24*60*60);
        if(!in_array(date('Y-m-d', $deliveryDate), $nonWorkingDays)){
            $daysToDelivery--;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a function in Python that returns different fixed values based
I am new to PHP and am trying to write a simple function that
I am trying to write a function that connects to a database and returns
I have a php function I wrote that will take a text file and
I am trying to write a php function to stop MySQL injection attempts. What
I am new to php and trying to write a login function. Bit stuck
I write a script for a alerter service. I used php connection_status function to
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
I want to write a function that takes an array of letters as an
I want to write a function that accepts two objects as parameters and compare

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.