I have a DateTime Object which holds an past timestamp.
I would now like to check if this DateTime is older than for example 48Hours.
How can I compore them best?
Regards
EDIT: Hi,
thanks for the help. Heres the helper method. Any naming suggesstions?
protected function checkTemporalValidity(UserInterface $user, $hours)
{
$confirmationRequestedAt = $user->getConfirmationTokenRequestedAt();
$confirmationExpiredAt = new \DateTime('-48hours');
$timeDifference = $confirmationRequestedAt->diff($confirmationExpiredAt);
if ($timeDifference->hours > $hours) {
return false;
}
return true;
}