I'm looking for a lean way to compare two times. One is the time, someone requested a new password(FOS UserBundle provides a Getter for that) and the other is the current time minus e.g. 10 minutes.
if($user->getPasswordRequestedAt() <= date("Y-m-d H:i:s", strtotime('-10 minutes'))){
return $this->render('@User/Resetting/no_resend.html.twig', array( 'username' => $username));
}
else {
return $this->render('@User/Resetting/check_email.html.twig', array(
'tokenLifetime' => ceil($this->container->getParameter('fos_user.resetting.retry_ttl') / 60),
));
So if someone requested a password already 10 minute ago, he gets to the page saying "You already requested a password, please wait 10 minute to retry.". If the request was longer than 10 minutes ago, the pages says "Email for password reset has been sent".
I would think the comparison is right that way but it's somehow always going to the "else" part.
Where's the mistake?