I'm using python to get time of 5 minutes ago.
Code:
import datetime
import time
now = datetime.datetime.now()
current_time = now.strftime(f"%Y-%m-%d %H:%M")
print(current_time)
2020-07-27 08:35:00
My question is how to get the time of 5 minutes ago.
something like
current_time-5mins
You may use datetime.timedelta()
:
datetime.datetime.now() - datetime.timedelta(minutes=5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With