如何在PHP结束后的月末添加一些天

My goal is to print a dueDate. The due date formula is end of the month adding the days which is 7 on my example. How can I make it possible? My echoed value on my actual result is "Due date: 08/01/1970" My expected result is "Due date: 07/06/2018"

$invoice_date = "11/05/2018";
$days  = 7;
$is_invoice = false;

$date = date("d/m/Y", strtotime($invoice_date));

if ($is_invoice) {
    $dueDate = date('d/m/Y', strtotime("+$day $days", strtotime($date)));
} else {
    $dueDate = date('t/m/Y', strtotime($date));
    $dueDate = date('d/m/Y', strtotime("+$day days", strtotime($date)));
}

echo "Due date: $dueDate";

Thanks in advance for the help

Try with the DateTime class:

$date = DateTime::createFromFormat('d/m/Y', '11/05/2018');

$dueDate = clone $date;
$dueDate->modify('+7 days');

echo 'Date : ' . $date->format('d/m/Y') . "
";
echo 'Due  : ' . $dueDate->format('d/m/Y') . "
";

Output:

Date : 11/05/2018 
Due : 18/05/2018

See it here: https://3v4l.org/BjUSK

I'd suggest you to use DateTime class and related functions:

$invoice_date = "11/05/2018";
$days = 7;

$input = date_create_from_format('d/m/Y', $invoice_date);
$result = $input->add(new DateInterval("P${days}D"));

$dueDate = $result->format('d/m/Y');

echo "Due date: $dueDate";

Output:

Due date: 11/05/2018

Your coding logic is perfect except the undefined variable error

$invoice_date = "11/05/2018";
$day  = 7;//in below statements used as day
$is_invoice = false;

$date = date("d/m/Y", strtotime($invoice_date));

if ($is_invoice) {
    $dueDate = date('d/m/Y', strtotime("+$day days", strtotime($date)));
} else {
    $dueDate = date('t/m/Y', strtotime($date));
    $dueDate = date('d/m/Y', strtotime("+$day days", strtotime($date)));
}

echo "Due date: $dueDate";

Undefined variable $day;//Change days to day

End of month + 7 days is how I read that ... correct me if I'm wrong:

$invoice_date= '11/05/2018';
$days= 7;

$dueDate= DateTime::createFromFormat('d/m/Y', $invoice_date);
$dueDate->modify('last day of this month')->modify('+7 days');
echo $dueDate->format('d/m/Y');

Invoice Date 11/5/2018 returns 7/6/2018

$invoice_date = "11-05-2018";
$day  = 7;//in below statements used as day
$is_invoice = false;

$date = date("Y/m/d", strtotime($invoice_date));

if ($is_invoice) {
$dueDate = date('d/m/Y', strtotime($date. ' + '.$day.' days'));
} else {
$dueDate = date('Y-m-t', strtotime($date));
$dueDate = date('d/m/Y', strtotime($dueDate. ' + '.$day.' days'));
}

echo "Due date: ".$dueDate;