-1

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?

FObersteiner
  • 16,957
  • 5
  • 24
  • 56
Evan Krause
  • 227
  • 1
  • 12

1 Answers1

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')
  • 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