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?
DateTime::diff.DateInterval, click link to its documentation.formatmethod.Use
if ($interval->format('%m') > 3)to test if it’s over three months. Notice that this is only the months portion of the interval, e.g. “3” of “2 years, 3 months”. Take the years into account as well. You should not just use days for this, since there’s no constant number of days in a month. 90 days and 3 months are not the same thing.