0

Im coding an a system like a product withdraw system, for example: Certain product category has X days to be withdrawn.

Category | Buziness Days
1 | 1
2 | 3
3 | 4
4 | 3
5 | 3
6 | 3
7 | 4

For example, today is 2019-05-22 wednesday: IF my product was category 7, + 4 days, my withdraw will be in 2019-05-28.

And I have another "problem", that system was build in PHP 4!

Thanks!

Hermus
  • 193
  • 2
  • 11
  • Great! So what have you [**tried so far**](http://meta.stackoverflow.com/questions/261592)? – Obsidian Age May 20 '19 at 23:17
  • I have done my JOB using DateTime and using modify('+5 weekdays') But this function just work on php 5 :( – Hermus May 20 '19 at 23:20
  • 1
    Well I hate to say it, but the first problem I would be solving is the fact that you are running PHP 4. Heck, PHP 5.5 has dropped support in 2016, and PHP 7.0 is already considered [*'end of life'*](https://www.php.net/supported-versions.php). PHP 4 [*hasn't been supported since 2008*](https://www.php.net/eol.php), and you're exposing yourself to a raft of security vulnerabilities by not updating. – Obsidian Age May 20 '19 at 23:24
  • Yeh I knew it, but it is not my project... his owner does not want to update that version. – Hermus May 20 '19 at 23:29

1 Answers1

1

Simple Date and strtotime has used and its been from PHP4

<?php
$CurrentDate = date('Y-m-d');
$businessdays = 4;
$checkloop = 0;
While($checkloop<$businessdays){
    $CurrentDate = date('Y-m-d', strtotime( "$CurrentDate + 1 day" ));
    $day = date('l', strtotime($CurrentDate));
    if($day!='Saturday' && $day!='Sunday')
        ++$checkloop;
}
print_r($CurrentDate);
print_r($day);
?>

Output

Current Date is 2019-05-21

2019-05-27 Monday

Rasa Mohamed
  • 882
  • 1
  • 6
  • 14