How to calculate how much time is left until a date?

Hello! There are two dates in format (today and the end date of the tariff):
date("d.m.Y H:i:s")
How to calculate how much time is left before the end of the tariff - months, days, hours, minutes. And then to check if exactly a month to do a certain action. Thanks in advance for any answers!
April 4th 20 at 01:00
3 answers
April 4th 20 at 01:02
April 4th 20 at 01:04
//Finding the number of days between two dates

$now = time(); // or your date as well
$your_date = strtotime("2020-01-31");
$datediff = $now - $your_date;

echo round($datediff / (60 * 60 * 24));

Mark the solution if helped)
April 4th 20 at 01:06
Convert to a UNIX date and calculate the difference, and then lead again to the initial state. This is a more universal way.

Find more questions by tags PHP