7

I've looked at

and loads of other articles on the internet but I cannot for the life of me understand how to convert the date_added field in the Chrome Bookmarks files (Windows) to a sensible number.

For instance 13024882639633631 is supposed to be a date in September 2013 but I tried all possible calculations in the 1st link I cited but can't seem to get a sensible date. It keeps calculating the date as 2010.

Community
  • 1
  • 1
keithxm23
  • 1,280
  • 1
  • 21
  • 41

3 Answers3

10

i have checked it with chrome bookmarks and it gave correct values for all. 13024882639633631 appears to be yesterday. check here https://code.google.com/p/chromium/codesearch#chromium/src/base/time/time_win.cc&sq=package:chromium&type=cs and search for MicrosecondsToFileTime

import datetime

def getFiletime(dt):
    microseconds = int(dt, 16) / 10
    seconds, microseconds = divmod(microseconds, 1000000)
    days, seconds = divmod(seconds, 86400)

    return datetime.datetime(1601, 1, 1) + datetime.timedelta(days, seconds, microseconds)

print format(getFiletime(hex(13024882639633631*10)[2:17]), '%a, %d %B %Y %H:%M:%S %Z')
Zaw Lin
  • 5,629
  • 1
  • 23
  • 41
  • Thanks Zaw Lin, this is perfect! I'm sorry I had made a mistake in my question where I'd written December instead of September. Anyway, I ran the code on several examples and this works great! I should've thought about looking in to the Chromium source. Big thanks Zaw Lin! – keithxm23 Sep 29 '13 at 16:52
  • This is based on [Unix epoch time](https://www.epochconverter.com/), but in microseconds (i.e. millionths of seconds) rather than seconds since midnight UTC of January 1, 1970. – Chiramisu Mar 24 '17 at 19:51
  • 1
    Chrome time.h explicitly tells it is based on Windows epoch 1601-01-01 00:00:00 UTC. Not Unix epoch or regular *nix timestamp. – mpe Mar 13 '20 at 20:02
7

This is just a conversion of the answer by Zaw LIn to python 3.

import datetime

def getFiletime(dtms):
  seconds, micros = divmod(dtms, 1000000)
  days, seconds = divmod(seconds, 86400)

  return datetime.datetime(1601, 1, 1) + datetime.timedelta(days, seconds, micros)

print( getFiletime(13024882639633631).strftime( '%a, %d %B %Y %H:%M:%S %Z' ) )

Output: Sat, 28 September 2013 22:57:19

Randy Skretka
  • 3,488
  • 3
  • 22
  • 14
2

The javascript equivalent of above python script

function ConvertToDateTime(srcChromeBookmarkDate) {
    //Hp --> The base date which google chrome considers while adding bookmarks
    var baseDate = new Date(1601, 0, 1);

    //Hp --> Total number of seconds in a day.
    var totalSecondsPerDay = 86400;

    //Hp --> Read total number of days and seconds from source chrome bookmark date.
    var quotient = Math.floor(srcChromeBookmarkDate / 1000000);
    var totalNoOfDays = Math.floor(quotient / totalSecondsPerDay);
    var totalNoOfSeconds = quotient % totalSecondsPerDay;

    //Hp --> Add total number of days to base google chrome date.
    var targetDate =  new Date(baseDate.setDate(baseDate.getDate() + totalNoOfDays));

    //Hp --> Add total number of seconds to target date.
    return new Date(targetDate.setSeconds(targetDate.getSeconds() + totalNoOfSeconds));
}

var myDate = ConvertToDateTime(13236951113528894);
var alert(myDate);
//Thu Jun 18 2020 10:51:53 GMT+0100 (Irish Standard Time)
hpsanampudi
  • 629
  • 6
  • 9