I am creating an app in Django where I have to send a token to a user but I want to make it expire after 5 minutes, now the issue I am getting time from django field in this format
token_time = Token.objects.filter(user_id=user_id).last().user_token_timestamp
current time = datetime.now().time()
is there any way to find the time difference in minutes in pythonic way, although I have done by converting the time into string and then striping it but it just feels like not a good way.
CodePudding user response:
Just subtract the current time from token time
td = current_time - token_time
mins = td.seconds / 60