I am making an API in which I need to check the token validity for a particular user and for that I am using DateTime function of php. I am saving a token and current time on login and I want token to be valid for 10 minutes, so when a user makes a request within first 10 minutes of its login I want to update the time validity of token.
$currentTime = new DateTime();
$curTime = $currentTime->format("Y-m-d H:i:s");
$time10MinutesAgo = new DateTime("10 minutes ago");
$time10Minutes = $time10MinutesAgo->format("Y-m-d H:i:s");
$token_time = $query1_r['token_time']; // value is stored in the db(mysql)
if (($curTime > $token_time) && ($token_time >= $time10Minutes)){}
first I was unable to pass the second condition but now even my page is not working.
$curTimeand$token_timeand$time10Minutesare strings, and notDateTimeobjects.