Convert Chrome history date/time stamp to readable format

datetime, google-chrome, macos, python

Solution

Use the `datetime` module. For example, if the number of microseconds in questions is 10**16:

>>> datetime.datetime(1601, 1, 1) + datetime.timedelta(microseconds=1e16)
datetime.datetime(1917, 11, 21, 17, 46, 40)
>>> _.isoformat()
'1917-11-21T17:46:40'

this tells you it was just past a quarter to 6pm of November 21, 1917. You can format `datetime` objects in any way you want thanks to their `strftime` method, of course. If you also need to apply timezones (other than the UTC you start with), look at third-party module pytz.

Problem

I originally posted this question looking for an answer with using python, got some good help, but have still not been able to find a solution. I have a script running on OS X 10.5 client machines that captures internet browsing history (required as part of my sys admin duties in a US public school). Firefox 3.x stores history in a sqlite db, and I have figured out how to get that info out using python/sqlite3. Firefox 3.x uses a conventional unixtimestamp to mark visits and that is not difficult to convert... Chrome also stores browser history in a sqlite db, but its timestamp is formatted as the number of microseconds since January, 1601. I'd like to figure this out using python, but as far as I know, the sqlite3 module doesn't support that UTC format. Is there another tool out there to convert Chrome timestamps to a human readable format?

Original source