Search code examples
c#google-chromedatetimegoogle-chrome-extension

In what format does Google Chrome store extension install dates


I am looking through the preferences file that Google Chrome uses for installed extensions and it would seem the install_time is stored in a weird format.

Here are a few sample dates from the file:

"install_time": "13018473436573431",

"install_time": "13018473437125431",
"lastpingday": "13024047600974141",

It does not convert to a DateTime in a C# application and it doesn't seem to be a normal javascript date(Those are only 13 numbers).

It's really weird that it is 17 numbers.

Here is some extra debug information, I output the date when I attempt to call new DateTime("install_date") and the number itself.

Program  Entry:
Ext Name: Clock
install_time: 1/2/0001 12:10:40 PM
install_time raw data: 13024070300259446
install_time (long):   13024070300259446

Program  Entry:
Ext Name: Googulator
install_time: 1/2/0001 12:10:40 PM
install_time raw data: 13024076154792655
install_time (long):   13024076154792655

Program  Entry:
Ext Name: Google News
install_time: 1/2/0001 12:10:40 PM
install_time raw data: 13024076389301659
install_time (long):   13024076389301659

Program  Entry:
Ext Name: Spotify - Music for every moment
install_time: 1/2/0001 12:10:40 PM
install_time raw data: 13024076418505659
install_time (long):   13024076418505659

Thanks


Solution

  • OK, think I might has worked it out, Well it certainly produce Today's date, you will need to work out if the time adds up. Consider the following javascrpt:

    var installTime = 13024070300259446;
    var convertedTime = ( installTime - 11644473600000000 ) / 1000 ;//divide by 1000 because we are going to add milliseconds on to the base date
    var date = new Date(convertedTime);
    alert(date);
    

    Here is a working example

    The original formula was obtained from here:

    Ref the history SQL statement in the OP, it can be modded a bit to get some human readable output from the timestamps. As already noted, the timestamps are in Webkit format, so needs some tweaking to get something intelligible.

    SELECT urls.url, urls.title, urls.visit_count, urls.typed_count, datetime(((urls.last_visit_time-11644473600000000)/1000000),'unixepoch','localtime') as last_visit_time, urls.hidden, datetime(((visits.visit_time-11644473600000000)/1000000),'unixepoch','localtime') as visit_time, visits.from_visit, visits.transition FROM urls, visits WHERE urls.id = visits.url

    However, the initial attempt of / 1000000 didn't work out, so I tried / 1000 instead and that did work! (see edit below as to why this didn't work)


    For completeness, as you have specifically used the C# tag, here is the C# version:

    long installTime = 13024070300259446;
    long convertedTime = ( installTime - 11644473600000000 ) / 1000000 ;//divide by 1000000 because we are going to add Seconds on to the base date
    DateTime date = new DateTime(1970,1,1,0,0,0,0);
    date = date.AddSeconds(convertedTime);
    Console.WriteLine(date);
    

    EDIT: After seeing Garrett's answer, it is clear why I had to divide by 1000 in my javascript example and he divides by 1000000 in his C# example. Because the javascript code is adding milliseconds onto the base date, where as C# is adding only seconds on to the base date. (NOTE: I have updated my C# code to reflect this)