fork download
  1. <?php
  2.  
  3. function getLastDeliveryDate($timestamp,$endOfMonth=true,$extraMonth=0){
  4.  
  5. $days = 0;
  6. $extraDays = 0;
  7. $endOfCurrentMonth = 0;
  8. $tag = 86400;
  9.  
  10. if($endOfMonth){
  11. $endOfCurrentMonth = date("t", $timestamp) - date("d",$timestamp);
  12. }
  13. date_default_timezone_set('Europe/Berlin');
  14. $date = new DateTime(date("Y-m-d", $timestamp));
  15. for($i=0;$i<$extraMonth;$i++){
  16. $date->modify("+1 month");
  17. $extraDays += $date->format("t");
  18. //$str .= "(" . $date->format("t") . ") ";
  19. }
  20.  
  21. $days = $endOfCurrentMonth + $extraDays;
  22.  
  23. return date("d.m.y", $timestamp + ($tag*$days)) . " $days";
  24.  
  25. }
  26.  
  27. echo getLastDeliveryDate(1436911200, false);
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
15.07.15 0