laravel subtract date code example

Example 1: laravel subtract date

$start_time = \Carbon\Carbon::parse($request->input('start_time'));
$finish_time = \Carbon\Carbon::parse($request->input('finish_time'));

$price = $request->input('price');

$result = $start_time->diffInDays($finish_time, false);

if ($result < 0) {
  $price = $price * $result;
}

Example 2: laravel subtract date

$start_time = \Carbon\Carbon::parse($request->input('start_time'));
$finish_time = \Carbon\Carbon::parse($request->input('finish_time'));

$price = $request->input('price');

$result = $start_time->diffInDays($finish_time, false);

if ($result < 0) {
  $price = $price * $result;
}

Tags:

Misc Example