I'm writing Python and I'm not a Python person.
I have a need to get a Unix timestamp of a time that is an arbitrary number of days ago.
In PowerShell, you can do something like this:
PS > Get-Date -Date (Get-Date).AddDays(-30) -UFormat %s
In Python, this is the best I came up with and it is ugly:
import re
import datetime
`int(re.split('\\.',str((datetime.datetime.now(datetime.UTC) - datetime.timedelta(days=30)).timestamp()))[0])`
That was from me reading module documentation and hacking away at it for a bit.
Surely, there is a better way.
I'm interfacing with an API that only takes datetime in Unix Time format and only down to the second in precision.
#Python #DateTime #UnixTime #EpochTime