I want to change b'1664348567 +0000'
to int and compare date.
I don't know how to convert this timestamp.
Asked
Active
Viewed 52 times
1

FObersteiner
- 22,500
- 8
- 42
- 72

gekson
- 99
- 2
- 8
-
`int(b'1664348567 +0000'.decode("utf-8").split(" ")[0])` ? To convert to datetime, see [Converting unix timestamp string to readable date](https://stackoverflow.com/q/3682748/10197418) : `datetime.fromtimestamp(i, tz=timezone.utc)`, would give 2022-09-28 07:02:47+00:00 with your example. – FObersteiner Nov 07 '22 at 14:42
-
Note (this applies to very very few people, but), when comparing `datetime` objects the returned delta represents the number of UTC clock ticks and not the number of elapsed seconds between the datetimes. // If you want the true number of seconds you may need another library like `skyfield`(`.timelib.Time`). // For example find the delta between two datetimes on either side of a leap second event; `1999-01-01T00:00:01 UTC` and `1998-12-31T23:59:58 UTC` 3 clock tick delta but 4 seconds elapsed. – KDecker Nov 07 '22 at 16:06