I use chrome timestamp and convert it do readable date but time isn’t right
JavaScript
x
2
1
timestamp_formated = str(datetime.datetime(1601, 1, 1) + datetime.timedelta(microseconds=last_visit_time))
2
Seems to be timezone need to be added
example for last_visit_time : 13292010189305268
Advertisement
Answer
Assuming that Chrome timestamps denote microseconds since 1601 UTC, you’ll want to make your datetime
aware:
JavaScript
1
6
1
from datetime import datetime, timezone, timedelta
2
3
epoch = datetime(1601, 1, 1, tzinfo=timezone.utc)
4
timestamp = epoch + timedelta(microseconds=last_visit_time)
5
print(timestamp)
6
If you want to format it for a non-UTC timezone, add a conversion step:
JavaScript
1
2
1
local_timestamp = timestamp.astimezone(the_timezone)
2