I have a DateTime object that contains the past timestamp.
Now I want to check if this DateTime is older than, for example, 48 hours.
How can I compost them better?
Hi
EDIT: Hi,
thanks for the help. Heres a helper method. Any suggestions for naming?
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;
}
source
share