I have a bonus system that only frees the bonus after 30 exact days of the user's registration. To compare the current date with the user's registration date so that I get how many days left to complete 30 exact days, I use the following code PHP
:
$time1 = new DateTime($user->date); //data do cadastro do usuário (MySQL timestamp)
$time2 = new DateTime(date("Y-m-d H:i:s")); //data atual
$interval = $time2->diff($time1);
$faltam_dias = 30 - $interval->d;
Doubt:
I took this test in the current month (June) that contains exactly 30 days. If the current month is 31 or 28/29 (February) days, how would you get the correct number of days to complete the 30 days of the bonus?