What is the format of Chrome's timestamps?

前端 未结 6 1221
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 00:33

I\'m using SQLite Database Browser to read information from a database containing the browsing history for Google Chrome. My current code that I am executing in the \"Execut

6条回答
  •  时光说笑
    2020-12-13 00:50

    Chromes Timestap is not Unixepoch!!

    Chrome's base time is 01/01/1601 00:00:00. To calculate local time, Chrome time has to be converted to seconds by dividing by one-million, and then the seconds differential between 01/01/1601 00:00:00 and 01/01/1970 00:00:00 must be subtracted. There are two ways you can do this, viz SQLite itself and Unix.

    SQLITE:

    sqlite> SELECT strftime('%s', '1601-01-01 00:00:00');
    -11644473600
    

    DATE:

    $ date +%s -d 'Jan 1 00:00:00 UTC 1601'
    -11644473600
    

    In both commands above, the "%s" represents unixepoch time. The commands calculate the number of seconds between unixepoch time (1970) and the subsequent date (Chrome time base, 1601). Note that the seconds are negative. Of course, this is because you have to count backwards from 1970 to 1601! With this information, we can convert Chrome time in SQLite like this:

    sqlite> SELECT datetime((time/1000000)-11644473600, 'unixepoch', 'localtime') AS time FROM table;
    

    Have a good read here.

提交回复
热议问题