Reputation: 1280
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.
Upvotes: 7
Views: 7566
Reputation: 679
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)
Upvotes: 2
Reputation: 3586
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
Upvotes: 7
Reputation: 5708
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')
Upvotes: 10