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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:07:29+00:00 2026-05-25T11:07:29+00:00

Dates in PHP are a nightmare for me so please help me out fellow

  • 0

Dates in PHP are a nightmare for me so please help me out fellow coders… I want to notify customers about the day their order will be delivered. It works like this:

I have 2 shipping zones, A & B. Orders for zone A are delivered each Monday, Wednesday & Friday, whereas zone B is on Tuesday, Thursday, Saturday. For each order, the delivery day is scheduled for the NEXT AVAILABLE day, depending on the zone. Please consider that if someone places an order on Monday the goods will be delivered on the NEXT available date, that would be Tuesday for zone B and Wednesday for zone A.

How can I calculate the NEXT AVAILABLE delivery date and notify the customer?

Thanks.

  • 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-25T11:07:29+00:00Added an answer on May 25, 2026 at 11:07 am

    Try this:

    // Info
    $date = array(date("d"), date("m"), date("Y"));
    $zone = "A";
    // ------
    
    $zones = array("A" => array(1 => "Monday",    
                                3 => "Wednesday", 
                                5 => "Friday")     
    
                  ,"B" => array(2 => "Tuesday",    
                                4 => "Thursday",   
                                6 => "Saturday")); 
    
    $found = false;
    $days_plus = 1; // always next day
    
    // Retrieve last day from the zone
    end($zones[$zone]);
    $last_day = key($zones[$zone]);
    
    do {
        $mk = mktime(0, 0, 0, $date[1], ($date[0] + $days_plus), $date[2]);
        $week = date("w", $mk);
    
        // if week not passed last day of zone
        if ($week <= $last_day)
        {
            if (!isset($zones[$zone][$week]))
            {
                $days_plus++;
            }
            else
            {
                $found = true;
            }
        }
        else
        {
            $days_plus++;
        }
    } while (!$found);
    
    echo "Next date: " . date("d/m/Y - l", $mk);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does php have a function to automatically convert dates to their day value, where
Possible Duplicates: PHP Day iterator I have 2 dates in PHP, how can I
I'm trying to compare two dates in PHP and figure out how many days
I want to compare two dates in PHP. One date is the date due,
I want to calculate the difference between two dates in php. I am trying
is there a library out there for PHP that formats dates in an informal
I am trying to do a little bit of math using dates in PHP.
I'm writing my first PHP app that has to directly deal with dates, and
I have a list of dates stored in MySQL using PHP. These were stored
I am coding in php, attempting to get the start\end dates and times for

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.