I used DateTime
to get the diff of two dates. Directly from the PHP documentation example:
$date1 = new DateTime('2012/03/15');
$date2 = new DateTime('2012/6/9');
$interval = $date1->diff($date2,true);
$days = $interval->format('%R%a days');
This will result in +86 days
, I wonder where can I get the reference for those %R%a
I don't know what they mean, but I just know by seeing that %R = +
while %a is number of days
.
Second, now by having the value 86
I can have at least a variable that I can use to tell that $date1
and $date2
is not within the length of 3 months (3 months is at least 90 days). I can simply use an if-else
for this, however for precision, is there another way (built-in PHP functions or library) to determine that the value I have is within the period of 3 months?