I’m returning information from an API and it uses this format to send timestamps, is there any easy way to return this time as Unix? It returns as a string and all the methods i’ve tried so far don’t work. Thank you for any help
Let’s say somehow you got the time as
To convert from string to a time object you can use:
from datetime import datetime t = datetime.strptime("2021-11-4T10:44:00", "%Y-%m-%dT%H:%M:%S")
Now you have a
datetime object which you can use to do as you wish. For example you want to convert it to
unix time format (which @pyzer shared as a comment)?