Jump to content

calculate weeks, weekends and days between any 2 dates?


rich_traff

Recommended Posts

Hi, i need to calculate the number of weekends, full weeks and any remaining week days (mon - fri, outside of full weeks) between any 2 dates stored as unix timestamp.

 

Can anyone suggest how to approach this?

 

obviously i can work out the number of total days easily with some math and from that work out the full weeks and remaining total days, i dont know where to start factoring in the weekends though...

 

can anyone help?

 

 

Link to comment
Share on other sites

I have not tested this code, but it should work if you modify it properly.

 

Basically, you need to do the math for this week, the last week, and count the days in between.

 

June 8 to July 20

June 8 = Wednesday (3)

Count workdays until end of date or end of week.

$dow=date("N");
$weekdays=0;
$weekends=0;

$totalDays=44; // 44 days

$x=0;
$x=8-$dow; //x days left in week - 5

   if ($x > 2) {
$weekdays+=$x-2; //weekdays = 3
$weekends++;
   }
   else {
$weekends+=x/2;
   }

$totalDays-=$x; // 39

$totalWeeks = floor($totalDays / 7); // (5.57) 5

$weekends+=$totalWeeks; // 5 + 1 = 6

$weekdays+=(5*$totalWeeks); // 25 + 3 = 28

$totalDays=$totalDays-((5*$totalWeeks)-($totalWeeks*2); // 39 - 25 - 10 = 4 days


   if ($totalDays <= 5) {
$weekdays+=$totalDays; //weekdays = 
   }
   else {
$weekdays+=5; // 5+28 = 33
$weekends+=($totalDays-5)/2;
   }

Link to comment
Share on other sites

Can you provide an example of how you expect the results? The problem I see is that a "Full" week includes a weekend. So, if the start date was a Sat. and run through 16 days ending on a Sun. You have two full weeks, but three sets of weekends. Just not sure how you want that returned - or what you consider a "full week". Is it mon-sun, sun-sat (a true week) or any 7 consecutive days.

Link to comment
Share on other sites

The example code I gave addresses 5 day work weeks and counts how many weekends there are. You can take how many weekends there are and multiply it by 2 to get how many actual weekend days there are. Additionally, you can add the total weeks plus the # of days in the first week and the # of days in the last week and that will tell you how many total 7 day weeks you have.

Link to comment
Share on other sites

Hi mjdamato, the situation is this,

 

It is for a car booking component where a user can book out a car for varying lengths of time at different rates.

 

rate 1 = '1 day' (any one day mon - fri)

rate 2 = '1 week' (any full 7 day week, so could be wed - tues)

rate 3 = '1 weekend' (any sat - sun)

 

So if someone booked 9 days starting on a tues, i need to calculate the cost for 1 full week and 2 days

If someone booked 3 days starting fri = 1 day & 1 weekend

 

I actually haven't considered what happens if someone just wants a sat or sun, but for now will treat it as any booking that falls onto either a sat or sun as 1 full weekend, ie - fri to sat = 1 day & 1 weekend

Link to comment
Share on other sites

Teynon, I've included a way of finding out the day of the week and incorporated your code into my script but am getting differing results, not sure if i've misinterpreted how to implement it though…

 

This is the full code so far…

 

$start_date // = dd/mm/yyyy
$end_date // = dd/mm/yyyy

			list($day,$month,$year) = explode("/", $start_date);
			$start_date_unixTime = mktime(0,0,0,$month,$day,$year);

			// reorders date then uses strtotime to find day of week
			$start_date_sql = ($year. '-' . $month . '-' . $day);
			$dayOfWeek = date('D', strtotime( $start_date_sql ));

				if ($dayOfWeek == 'Mon')
					{$dow = 1;}
				if ($dayOfWeek == 'Tue')
					{$dow = 2;}
				if ($dayOfWeek == 'Wed')
					{$dow = 3;}
				if ($dayOfWeek == 'Thu')
					{$dow = 4;}
				if ($dayOfWeek == 'Fri')
					{$dow = 5;}
				if ($dayOfWeek == 'Sat')
					{$dow = 6;}
				if ($dayOfWeek == 'Sun')
					{$dow = 7;}

		// creates unix timesstamp from end date
		$end_date = JRequest::getString('end_date', '');

			list($day,$month,$year) = explode("/", $end_date);
			$end_date_unixTime = mktime(0,0,0,$month,$day,$year);


			// number of days between dates
			$seconds = $end_date_unixTime - $start_date_unixTime;
			$days = ($seconds / 86400) + 1;

$weekdays=0;
			$weekends=0;

			$totalDays= $days; 

			$x=0;
			$x=8-$dow; //x days left in week - 5

			   if ($x > 2) {
				$weekdays+=$x-2; //weekdays = 3
				$weekends++;
			   }
			   else {
				$weekends+=x/2;
			   }

			$totalDays-=$x; // 39
			$totalWeeks = floor($totalDays / 7); // (5.57) 5
			$weekends+=$totalWeeks; // 5 + 1 = 6
			$weekdays+=(5*$totalWeeks); // 25 + 3 = 28
			$totalDays=$totalDays-((5*$totalWeeks)-($totalWeeks*2)); // 39 - 25 - 10 = 4 days

			   if ($totalDays <= 5) {
				$weekdays+=$totalDays; //weekdays = 
			   }
			   else {
				$weekdays+=5; // 5+28 = 33
				$weekends+=($totalDays-5)/2;
			   }

 

if i then output $days, $weekdays, $weekends, $totalweeks

these are some results from different date ranges

 

(Mon) 1/8/2011 - 7/8/2011: days = 7, week days = 5, weekends = 1, total weeks = 0 

days - Correct 'C',  week days - Correct 'C', weekends - Correct 'C', total weeks - Wrong 'W'

 

(Mon) 1/8/2011 - 3/8/2011: days = 3, week days = -1, weekends = 0, total weeks = -1 

days - C,  week days - W, weekends - C, total weeks - W - notice the '-1' for each

 

(Wed) 3/8/2011 - 16/8/2011: days = 14, week days = 13, weekends = 2.5, total weeks = 1

days - C,  week days - W, weekends - W, total weeks - W

 

(Mon) 4/7/2011 - 29/8/2011: days = 57, week days = 45, weekends = 20, total weeks = 7

days - C,  week days - W, weekends - W, total weeks - W

 

Now I know i haven't added the days from the first and last weeks to the total weeks as you have said so im not expecting those to be right but not sure where to grab these from, can you explain?

 

Also, the other calculations are correct sometimes, not others...

Link to comment
Share on other sites

Here you go. Just pass the function two dates. It will return an array with values for the following: "total weeks", "remaining weekdays" and "remaining weekend days". You can simply divide the weekend days by two to get 2-day weekends.

 

function getDateParts($startDate, $endDate)
{
    //Normalize dates for 12noon to ensure full days calulation
    $startDate = strtotime(date("d F Y", $startDate) . " 12:00pm");
    $endDate   = strtotime(date("d F Y", $endDate) . " 12:00pm");

    //Initialize array for return variable
    $return['totalWeeks'] = 0;
    $return['singeWeekendDays'] = 0;
    $return['singleWeekdays'] = 0;

    //Calculate total days, weeks, and remaining days
    $totalDays = round(($endDate-$startDate) / (60*60*24)) + 1;
    $return['totalWeeks'] = floor($totalDays/7);
    $remianingDays = $totalDays - ($return['totalWeeks']*7);

    //Determine types of remaining days
    while($remianingDays>0)
    {
        if(date("N", $endDate)>5)
        {
            $return['singeWeekendDays']++;
        }
        else
        {
            $return['singleWeekdays']++;
        }
        //Change end date to prev date, and reduce remaining days
        $endDate = strtotime(date("d F Y", $endDate) . " -1 day");
        $remianingDays--;
    }

    return $return;
}

 

Using dates of June 1 and June 12 of this year the result is

Array
(
    [totalWeeks] => 1
    [singleWeekdays] => 3
    [singeWeekendDays] => 2
)

Link to comment
Share on other sites

mjdamato's example is close, but you have to take in to account that the first day could start on saturday or sunday, this would modify the results. I have taken my lunch break and made a working copy:

 

<?php
function getDateRange($start_date, $end_date) {

	$startDate=strtotime(date("d M Y", mktime(12,0,0,substr($start_date, 3, 2), substr($start_date, 0, 2), substr($start_date, 6, 4))));
	$endDate=strtotime(date("d M Y", mktime(12,0,0,substr($end_date, 3, 2), substr($end_date, 0, 2), substr($end_date, 6, 4))));

	$totalDays = ($endDate-$startDate)/60/60/24;
	$results["TotalDays"] = $totalDays+1;

	$totalWeeks = $totalDays / 7;

	$dow=date("N", $startDate);

	$weekdays=0;
	$weekends=0;

	$x=8-$dow;

   		if ($x > 2) {
		$weekdays+=$x-2; //weekdays = 3
		$weekends++;
	}
	else {
		$weekends+=$x/2;
	}

	$totalDays-=$x; // 39

	$totalWeeks = floor($totalDays / 7); // (5.57) 5

	$weekends+=$totalWeeks; // 5 + 1 = 6

	$weekdays+=(5*$totalWeeks); // 25 + 3 = 28

	$totalDays=$totalDays-((5*$totalWeeks)+($totalWeeks*2));


   		if ($totalDays <= 5) {
		$weekdays+=$totalDays+1; //weekdays = 
   		}
   		else {
		$weekdays+=5; // 5+28 = 33
		$weekends+=($totalDays-5)/2;
   		}

	$results["Range"] = date("dMY", $startDate) ." to ". date("dMY", $endDate);
	$results["TotalWeeks"] = $totalWeeks;
	$results["weekends"] = $weekends;
	$results["weedays"] = $weekdays;
	return $results;
}


$start_date = "12/06/2011"; // = dd/mm/yyyy
$end_date = "20/06/2011"; // = dd/mm/yyyy
$results = getDateRange($start_date, $end_date);
echo "<pre>";
print_r($results);
echo "</pre>";
$start_date = "01/06/2011"; // = dd/mm/yyyy
$end_date = "20/08/2011"; // = dd/mm/yyyy
$results = getDateRange($start_date, $end_date);
echo "<pre>";
print_r($results);
echo "</pre>";
$start_date = "12/05/2011"; // = dd/mm/yyyy
$end_date = "20/06/2011"; // = dd/mm/yyyy
$results = getDateRange($start_date, $end_date);
echo "<pre>";
print_r($results);
echo "</pre>";


?>

 

Results:

Array
(
    [TotalDays] => 9
    [Range] => 12Jun2011 to 20Jun2011
    [TotalWeeks] => 1
    [weekends] => 1.5
    [weedays] => 6
)
Array
(
    [TotalDays] => 81
    [Range] => 01Jun2011 to 20Aug2011
    [TotalWeeks] => 10
    [weekends] => 11
    [weedays] => 59
)
Array
(
    [TotalDays] => 40
    [Range] => 12May2011 to 20Jun2011
    [TotalWeeks] => 5
    [weekends] => 6
    [weedays] => 28
)

Link to comment
Share on other sites

mjdamato's example is close, but you have to take in to account that the first day could start on saturday or sunday, this would modify the results.

 

What are you talking about. He stated he wanted full weeks (7 consecutive days) regardless of when that week started.

rate 2 = '1 week' (any full 7 day week, so could be wed - tues)

 

Besides there are several problems with your code. What is this line for

$totalWeeks = $totalDays / 7;

'

when you never even use that variable before redefining that variable on this line?

$totalWeeks = floor($totalDays / 7); // (5.57) 5

 

That's a minor problem. A bigger issue is that your code is just plain broken. Using the dates Start: March 11, 2011 and End: March 20, 2011 the results are:

Array
(
    [TotalDays] => 9.95833333333
    [Range] => 11Mar2011 to 20Mar2011
    [TotalWeeks] => 0
    [weekends] => 1.47916666667
    [weedays] => 6
)

 

So, what is the rate on 1.47916666667 weekends?

 

Also, the OP stated he needed to do this "...between any 2 dates stored as unix timestamp.". Which your function does not support - requiring the dates to be converted before calling the function.

Link to comment
Share on other sites

mjdamato,

 

  Are your feelings hurt? You sound like a child. I wasn't saying anything about you other than your code didn't work properly. And you're right, you identified an error in mine, where if the dates were too close together, it wouldn't calculate the days right.

 

  However, the logic in your code says 2 weekends. If you look at the calendar between June 1st and June 12th.... I seem to be counting 4 weekend days. Saturday the 4th, Sunday the 5th, Saturday the 11th, and Sunday the 12th.

 

  You seem to be offended, so I'll make this clear. I don't care. All I will say is that I was not directing anything towards you, I was trying to help the OP.

 

 

  As for the OP, I will update the code to fix the error tonight when I get off of work.

 

Tom

Link to comment
Share on other sites

Nothing going on at work, so I pasted my code into "writecodeonline.com" and updated it on there.

 

This code should work, if you find any issues, let me know.

 

<?php
function getDateRange($start_date, $end_date) {

	$startDate=strtotime(date("d M Y", mktime(0,0,0,substr($start_date, 3, 2), substr($start_date, 0, 2), 

substr($start_date, 6, 4))));
	$endDate=strtotime(date("d M Y", mktime(0,0,0,substr($end_date, 3, 2), substr($end_date, 0, 2), substr

($end_date, 6, 4))));


	$totalDays = round(($endDate-$startDate)/60/60/24);
	$results["TotalDays"] = $totalDays+1;
			$totalWeeks = $totalDays / 7;

	$dow=date("w", $startDate);
	if ($dow == 0) { $dow=6; }
	$dow++;
	$weekdays=0;
	$weekends=0;

	$x=8-$dow;
	if ($x > 2) {
		$weekdays+=$x-2; //weekdays = 3
		$weekends++;
	}
	else {
		$weekends+=$x/2;
	}
	$totalDays-=$x; // 39	
	$totalWeeks = floor($totalDays / 7); // (5.57) 5

	$weekends+=$totalWeeks; // 5 + 1 = 6

	$weekdays+=(5*$totalWeeks); // 25 + 3 = 28

	$totalDays=$totalDays-((5*$totalWeeks)+($totalWeeks*2));


   		if ($totalDays <= 5) {
		$weekdays+=$totalDays+1; //weekdays = 
   		}
   		else {
		if ($totalDays == 7) {
			$totalWeeks++;
		}
		$weekdays+=5; // 5+28 = 33
		$weekends+=($totalDays-5)/2;
   		}

	$results["Range"] = date("dMY", $startDate) ." to ". date("dMY", $endDate);
	$results["TotalWeeks"] = $totalWeeks;
	$results["weekends"] = $weekends;
	$results["weedays"] = $weekdays;
	return $results;
}


$start_date = "12/06/2011"; // = dd/mm/yyyy
$end_date = "20/06/2011"; // = dd/mm/yyyy
$results[0] = getDateRange($start_date, $end_date);
$start_date = "01/06/2011"; // = dd/mm/yyyy
$end_date = "20/08/2011"; // = dd/mm/yyyy
$results[1] = getDateRange($start_date, $end_date);
$start_date = "11/03/2011"; // = /mm/yyyy
$end_date = "20/03/2011"; // = dd/mm/yyyy
$results[2] = getDateRange($start_date, $end_date);
echo "<pre>";
print_r($results);
echo "</pre>";
?>

Array
(
    [0] => Array
        (
            [TotalDays] => 9
            [Range] => 12Jun2011 to 20Jun2011
            [TotalWeeks] => 1
            [weekends] => 1.5
            [weedays] => 6
        )

    [1] => Array
        (
            [TotalDays] => 81
            [Range] => 01Jun2011 to 20Aug2011
            [TotalWeeks] => 10
            [weekends] => 11.5
            [weedays] => 57
        )

    [2] => Array
        (
            [TotalDays] => 10
            [Range] => 11Mar2011 to 20Mar2011
            [TotalWeeks] => 1
            [weekends] => 2
            [weedays] => 6
        )

)

 

If you want the unix timezone, simply remove the conversion in the date...

 

$startDate=strtotime(date("d M Y", mktime(0,0,0,substr($start_date, 3, 2), substr($start_date, 0, 2), 

substr($start_date, 6, 4))));
	$endDate=strtotime(date("d M Y", mktime(0,0,0,substr($end_date, 3, 2), substr($end_date, 0, 2), substr

($end_date, 6, 4))));

Link to comment
Share on other sites

Are your feelings hurt? You sound like a child. I wasn't saying anything about you other than your code didn't work properly.

No my feelings aren't hurt. And you are the first one to make disparaging remarks.

 

And you're right, you identified an error in mine, where if the dates were too close together, it wouldn't calculate the days right.

The reason your code wasn't calculating right has nothing to do with how close together the dates are. I intentionally didn't state why your code failed to see if you realized the error. In the last code you posted I see you corrected that error using the logic I had originally provided. So, either you "know" why the error occurred and solved it with the same solution or you still have no idea why the error occurred and just solved it by copying and pasting something with no understanding of why it was a problem in the first place. Since you didn't state the reason for the error (which has a simple explanation) I assume the latter.

 

However, the logic in your code says 2 weekends. If you look at the calendar between June 1st and June 12th.... I seem to be counting 4 weekend days. Saturday the 4th, Sunday the 5th, Saturday the 11th, and Sunday the 12th.

No, my code returned 2 weekend "days" and 1 full week. As per the more detailed requirements in the follow up post from the OP that I requested, this is what he needed, i.e. full weeks and any remaining weekdays/weekends. But, since he admitted that he didn't know what to do if there was only one weekend day (and not a full weekend) the code returned the number of "remaining" weekend days. He can then determine what to do if the value is a 1 (one remaining weekend day) or a 2 (a full weekend). There would only ever be 1 or 2 remaining weekend days. But, it could just have easily been modified to return a 1 for a full weekend of a .5 for a single weekend day.

 

You seem to be offended, so I'll make this clear. I don't care. All I will say is that I was not directing anything towards you, I was trying to help the OP.

No, I am not offended. I just don't understand your need to "fix" something that is not broken and replace it with something that is flawed when you don't understand the requirements or, more importantly, the dynamics of the intricacies involved (dates and time).

Link to comment
Share on other sites

Correction to my code: if ($dow == 0) { $dow=6; } $dow++; should be

 

if ($dow == 0) { $dow=7; } // No $dow++.

 

The site I tested it on didn't have the latest PHP version and thus doesn't support date("N") so I had to improvise.

 

mj, your code will return a maximum of two weekend days no matter how long the date range is.

 

 

The reason my code was returning a decimal is because the date range you specified indicated daylight savings time. Rounding fixes that issue.

 

Hi, i need to calculate the number of weekends, full weeks and any remaining week days (mon - fri, outside of full weeks) between any 2 dates stored as unix timestamp.

 

Calculate number of weekends. ^^^

 

As for "your logic" are you considering that the "$totalDays / 7 is your logic? I am pretty sure I posted that logic before you. Besides, thats pretty basic logic... I do see that I put it in there twice, but that's possibly because I recreated the code via web browser. Whatever, I make mistakes. Whatever the case, we all make mistakes and it's pretty obvious that you're upset. It's entertaining, though.

 

Link to comment
Share on other sites

Not upset at all, as I said you are the one that started with the disparaging remarks not me. I may have been criticizing your code, you are the one that decided to make it personal.

 

mj, your code will return a maximum of two weekend days no matter how long the date range is.

Yes, exactly. The OPs first request was vague and the reference you stated was misleading. That is why I asked for the OP to provide a clearer definition of the issue - which he did.

It is for a car booking component where a user can book out a car for varying lengths of time at different rates.

 

rate 1 = '1 day' (any one day mon - fri)

rate 2 = '1 week' (any full 7 day week, so could be wed - tues)

rate 3 = '1 weekend' (any sat - sun)

 

So if someone booked 9 days starting on a tues, i need to calculate the cost for 1 full week and 2 days

If someone booked 3 days starting fri = 1 day & 1 weekend

 

In the specific example he states he wants the result of 1 week and 2 week days (i.e. he doesn't need a weekend in the results because it is included in the full week). Based upon those refined requirements it is obvious he doesn't need ALL the weekends if they are included in the full weeks (7 consecutive days). If you are charging the customer for full weeks, you wouldn't also charge separately for the weekends included in those full weeks. That being the case, you would only ever have 1 or 2 weekend days that are not included in a full week for any time period.

Link to comment
Share on other sites

mjdamato,

 

  Fair enough, I'll admit when I'm wrong. I think it's pretty obvious you were being cynical in the way you replied the first time, however. Which is why I replied the way I did. I find that stuff humorous. (I'm in the army and we act like this all the time.) Only two months left in the military, though, so I probably should stop that since the civilian world takes it all seriously.

 

  But just to keep the conversation going, I like my function better.

 

Tom

Link to comment
Share on other sites

Cynical? I don't think so. Condescending? Perhaps. Critical? Definitely. But, the only statement I made that was even remotely condescending was

So, what is the rate on 1.47916666667 weekends?

But, I consider that humor, sorry if you took that personal. I said absolutely nothing about you or your character - only your code.

 

I'm in the army and we act like this all the time.

I was in the Army too. But, I don't see your point.

Link to comment
Share on other sites

Where are the mods?

 

@teynon - If you post code to the world, be prepared to get criticized on it. Congrats for 'liking' your code better, but from a logical, efficiency and simplistic standpoint, mjdamato has provided better code - on top of being formatted and presented better.

 

I don't understand why you're getting in a huff. You provided archaic, non-working code and got called on it. mjdamato's reply was on topic. Yours was off. Keep that stuff to PMs.

Link to comment
Share on other sites

Hi Teynon, Mjdamto

 

Thanks to both of you for contributing to this, i really appreciate your time, you've helped me out a lot.

 

Im unable to work on this today but will look at all the examples over the weekend and let you know which works out best.

Link to comment
Share on other sites

  • 2 weeks later...

Hi, i realise this is an old thread now but i have to make a change to the solution and am not sure how to do it so thought id repost here rather than start a new topic

 

I am using this function supplied earlier in this thread by mjdamato

 

<?php
function getDateParts($startDate, $endDate)
{
    //Normalize dates for 12noon to ensure full days calulation
    $startDate = strtotime(date("d F Y", $startDate) . " 12:00pm");
    $endDate   = strtotime(date("d F Y", $endDate) . " 12:00pm");

    //Initialize array for return variable
    $return['totalWeeks'] = 0;
    $return['singeWeekendDays'] = 0;
    $return['singleWeekdays'] = 0;

    //Calculate total days, weeks, and remaining days
    $totalDays = round(($endDate-$startDate) / (60*60*24)) + 1;
    $return['totalWeeks'] = floor($totalDays/7);
    $remianingDays = $totalDays - ($return['totalWeeks']*7);

    //Determine types of remaining days
    while($remianingDays>0)
    {
        if(date("N", $endDate)>5)
        {
            $return['singeWeekendDays']++;
        }
        else
        {
            $return['singleWeekdays']++;
        }
        //Change end date to prev date, and reduce remaining days
        $endDate = strtotime(date("d F Y", $endDate) . " -1 day");
        $remianingDays--;
    }

    return $return;
}

 

which takes a start date and end date and returns the number of full weeks (any 7 days), the remaining weekend days and week days. It currently counts any 7 day period as a week, so tues - mon is a valid week.

 

The parameters have now changed though and i need to only count mon - sun as a full week.

 

So if someone booked from wed to the following following fri, it should return 2 weekend days and 8 week days

 

Where as if someone books from sun to the following tues, returned should be 1 week, 1 weekend day and 2 week days

 

So, i need to input any start and end date and return;

The number of full weeks (mon - sun)

The number of remaining weekend days (sat, sun)

The number of remaining week days (mon - fri)

 

Now, i assume a way to adapt the function to give the full weeks would have something to do with counting any 7 day periods from the first date("N") to =1, then work out the remainders before and after this, but am not sure if this would be correct and even less sure how to implement it…

 

can anyone help?

Link to comment
Share on other sites

Ok, you need to go find the person that changed the requirements and hit them upside the head with a blunt object. I can't tell you how many times we have encountered significant rework because what should be simple decisions are not thought out before hand. Anyway, the code below should work. I did some testing, but not extensive.

 

function getDateParts($startDate, $endDate)
{
    //Normalize dates for 12noon to ensure full days calulation
    $startDate = strtotime(date("d F Y", $startDate) . " 12:00pm");
    $endDate   = strtotime(date("d F Y", $endDate) . " 12:00pm");

    //Initialize array for return variable
    $return['totalWeeks'] = 0;
    $return['singeWeekendDays'] = 0;
    $return['singleWeekdays'] = 0;

    //Calculate total days in range
    $totalDays = round(($endDate-$startDate) / (60*60*24)) + 1;

    //Calculate full weeks, remaining week days, and remaining weekend days
    for($day=0; $day<$totalDays; $day++)
    {
        $checkDate = strtotime(date("d F Y", $startDate) . " +{$day} days");
        if(date("N", $checkDate)>5)
        {   //Add weekend day
            $return['singeWeekendDays']++;
        }
        elseif(date("N", $checkDate)==1 && ($totalDays-$day)>6)
        {   //Add full week
            $return['totalWeeks']++;
            $day+=6;
        }
        else
        {   //Add week day
            $return['singleWeekdays']++;
        }
    }

    return $return;
}

Link to comment
Share on other sites

you need to go find the person that changed the requirements and hit them upside the head with a blunt object.

Tell me about it... At least its only one parameter thats changed, i've had a lot worse before.

 

Your rewrite works perfectly, thanks again for your time

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.