2
I have a bonus system that only releases the bonus after 30 days of exact user registration. To compare the current date with the date of the user’s registration so that I get how many days to complete the exact 30 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 did this test in the current month (June) which contains exactly 30 days. If the current month has 31 or 28/29(February) days, how would you get correctly how many days would be left to complete the 30 days bonus?