vendredi 17 mai 2019

If Statement Passed Time Current Time

I want to check if certain time (20 minutes) has passed in comparison to the current time before any code is executed.

import datetime

lastactivity = "2019-05-17 10:02:25"

currentime = str(datetime.datetime.now())

if lastactivity < currentime:
    print("it's time")

How do i go about doing this? i can't figure it out, the comparison operator will result in true the second is greater than then the passed time.. How do i add the 20 minutes check in there? also the lastactivity variable i'm getting that in string by default, would i need to change that to float/integers to be able to add my 20 minutes check?

Aucun commentaire:

Enregistrer un commentaire