The Chrome bookmarks file is JSON which contains a "date_added" value that represents a particular date and time, e.g.
{
"checksum": "05b8bba8b5f0e9ad1cc8034755557735",
"roots": {
"bookmark_bar": {
"children": [ {
"children": [ {
"date_added": "13170147422089597",
"id": "121",
"name": "NativeScript: Getting Started Guide",
"type": "url",
"url": "https://docs.nativescript.org/tutorial/chapter-0"
} ],
...
I have tried treating the value as nanoseconds and passing to the Date constructor:
new Date(13170147422089597 / 1000); // 2387-05-07T06:17:02.089Z
but that doesn't seem correct.
How should the value "13170147422089597" be converted to a Date or date string?
Just for those who need the same algorithm in .NET / PowerShell, here is the implementation in PowerShell (the .NET version should be then pretty straightforward):
$timeValue = 13268127530603048
$epoch = (New-Object DateTime(1601, 1, 1)).Ticks
$utcTime = New-Object DateTime(($epoch + $timeValue * 10), [System.DateTimeKind]::Utc)
$utcTime.ToLocalTime()
The Chrome bookmarks time value is microseconds from an epoch of 1601-01-01T00:00:00Z. To convert to a Date:
E.g.
var timeValue = '13170147422089597';
new Date(Date.UTC(1601,0,1) + timeValue / 1000); // 2018-05-07T06:17:02.089Z
Storing the value Date.UTC(1601,0,1) as a constant (-11644473600000) and converting to a function gives:
function chromeTimeValueToDate(tv) {
var epoch = -11644473600000;
return new Date(epoch + tv / 1000);
}
// Example
['13170147422089597',
'13150297844686316',
'13115171381595644'].forEach( tv => {
console.log(chromeTimeValueToDate(tv))
});
It's WebKit/Chrome Timestamp, representing microseconds since 1601/1/1 UTC.
It comes from Windows NT Timestamp (as 100-nanoseconds since 1601/1/1 UTC), available as FileTime structure.
There is an online WebKit/Chrome Timestamp Converter in https://www.epochconverter.com/webkit
which provides its code there as well.
However the code is in Python2, so I transcribe it to Python3 as below:
import datetime
def date_from_webkit(webkit_timestamp):
epoch_start = datetime.datetime(1601,1,1)
delta = datetime.timedelta(microseconds=int(webkit_timestamp))
print(epoch_start + delta) # py3 requires () for print
date_from_webkit(int(input('Enter a Webkit timestamp to convert: '))) # py3 integrates raw_input() and input() into input()
I like to prototype these things in a spreadsheet and then it should be trivial to code the coded formula in whichever language you happen to be working with.
Formula = "2001-1-1" + A2/24/60/60/1000000 - 400*365.25+3+7/24
Explanation:
For example, Chrome's Bookmark [date_added] value is "13190650905699900", so: "2001-1-1"+ 13190650905699900/24/60/60/1000000 - 400*365.25+3+7/24 yields 12/30/2018 8:41:46pm
You can find the Bookmarks file here:
%LOCALAPPDATA%\Google\Chrome\User Data\Default\Bookmarks
as of current version of Chrome (v71)
PS - Window Time utility can do it for you too if all you want is a quick one-time conversion: type
w32tm.exe /ntte 131906509056999000
at a command prompt - notice I had to add a '0' (or multiply by 10).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With