I'm trying to build an app where I can an API request, but I want to send a time query where the time is the time 10 minutes ago. How should I go about doing that in Python?
Asked
Active
Viewed 71 times
-1
-
1Does this answer your question? [How to get UTC time in Python?](https://stackoverflow.com/questions/15940280/how-to-get-utc-time-in-python) – M Z Nov 30 '20 at 22:19
-
this: https://stackoverflow.com/a/58294845/10197418 – FObersteiner Dec 01 '20 at 09:14
1 Answers
1
Something like this should do the trick.
datetime.now(timezone.utc)
Alternatively, you could try this as well. For me, I had to add 5 hours because I'm in EST, so do the respective conversion.
curTime = (datetime.datetime.now() + datetime.timedelta(hours=5)).strftime('%Y-%m-%d %H:%M:%S')
Achintya Kumar
- 80
- 8
-
For handling time zones and related conversions, you could have a look at e.g. https://stackoverflow.com/a/65087160/10197418 – FObersteiner Dec 06 '20 at 13:15