To work with dates in PHP there is a very useful library called Carbon. https://carbon.nesbot.com/docs/
This library includes a multitude of operations with dates, among which you will of course find the difference between days of two dates.
Assuming you have the dates in “MySQL format”, something like 2019-10-15. You would have to do the following:
$currentDate = Carbon::createFromFormat(‘Ym-d’, $currentDate); $shippingDate = Carbon::createFromFormat(‘Ym-d’, $shippingdate); $diff_in_days = $currentDate->diffInDays($shippingDate);
I don’t know which date you want to subtract from which other. Maybe your operation is the opposite. Although this is already a minor problem.
$diff_in_days = $shippingDate->diffInDays($currentDate);
Depending on the format you have on your date, the generation of the Carbon objects can change, but there it is only to consult the documentation of the library.