Calculating working days to a date!

Asked

Viewed 54 times

1

I’m doing a product withdrawal system, for example: Certain product category has X working days to be removed.

Category | Business days
1 | 1
2 | 3
3 | 4
4 | 3
5 | 3
6 | 3
7 | 4

For example, today is day 22/05/2019 Wednesday: If I pick a product with category 7 are + 4 working days, in case the delivery from the day 28/05/2019.

with this Function what I can do is if the delivery date falls on a weekend, it pushes the date to the next business day... but it is wrong..

function verificaFinalSemana($data){
// sabado = 6
// domingo = 0
if(date('w', strtotime($data)) == 6 || date('w', strtotime($data)) == 0){
    $nova_data = date('Y-m-d', strtotime($data . "+1 day"));
    verificaFinalSemana($nova_data);
}else{;
    $nova_data = $data;
}
return date('d/m/Y', strtotime($nova_data));
}

How do I fix this?

An aggravating thing is, the system I’m working on is PHP 4.

Grateful!

  • Check out https://answall.com/questions/61369/script-de-dias-%C3%Bateis

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.