fork(8) download
  1. <?php
  2.  
  3. function calcularPrazo($prazoPrevio){
  4. $dataSTR = date('d-m-Y'); //hoje
  5.  
  6. $data = explode('-',$dataSTR);
  7.  
  8. //time do dia que sera o dia final do prazo previo
  9. $time = mktime(0, 0, 0, $data[1], intval($data[0]) + $prazoPrevio, $data[2]);
  10.  
  11. $diaSemana = date("w", $time);
  12.  
  13. switch($diaSemana){
  14. case 0: //domingo
  15. //subtrair mais dois dias
  16. $prazoPrevio -= 2;
  17. break;
  18. case 6: //sabado
  19. //subtrair mais um dias
  20. $prazoPrevio -= 1;
  21. break;
  22. }
  23.  
  24. $time = mktime(0, 0, 0, $data[1], intval($data[0]) + $prazoPrevio, $data[2]);
  25. return date('d-m-Y',$time);
  26. }
  27.  
  28.  
  29.  
  30. echo calcularPrazo(11);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
19-12-2014