How to parse Chrome bookmark's "date_added" value as a date


Rob

Chrome bookmark files are JSON containing "date_added" values ​​representing a specific 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 try to treat the value as nanoseconds and pass to Date constructor:

new Date(13170147422089597 / 1000); // 2387-05-07T06:17:02.089Z

But that doesn't seem right.

How should the value "13170147422089597" be converted to a date or date string?

Rob

Chrome bookmarks have time values ​​in microseconds since epoch 1601-01-01T00:00:00Z. Convert to date:

  1. Divide by 1,000 to get milliseconds
  2. Adjusted to the epoch of 1970-01-01T00:00:00Z
  3. Pass the resulting value to the Date constructor

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))
});

Related


How to parse date_added field in Chrome bookmarks file?

keithxm23 i have seen Google bookmarks export date format? http://productforums.google.com/forum/#!topic/chrome/-ujeAr1_YFQ Convert 64bit Windows datetime in Python and loads of other articles on the internet, but for the life of me I can't figure out how to c

How to set bookmark's icon via chrome.bookmark api?

Matisse Wessels I'm importing bookmarks via a chrome extension and I want to set the icon for each bookmark. I can't find any way to do this in the docs . The type doesn't seem to have an icon propertyBookmarkTreeNode Rob W No, you cannot change the favicon th

How to set bookmark's icon via chrome.bookmark api?

Matisse Wessels I'm importing bookmarks via a chrome extension and I want to set the icon for each bookmark. I can't find any way to do this in the docs . The type doesn't seem to have an icon propertyBookmarkTreeNode Rob W No, you cannot change the favicon th

How to set bookmark's icon via chrome.bookmark api?

Matthijs Wessels I'm importing bookmarks via chrome extension and would like to set the icon for each bookmark. I can't find any way to do this in the docs . The type doesn't seem to have an icon propertyBookmarkTreeNode Rob W No, you cannot change the favicon

How to set bookmark's icon via chrome.bookmark api?

Matthijs Wessels I'm importing bookmarks via chrome extension and would like to set the icon for each bookmark. I can't find any way to do this in the docs . The type doesn't seem to have an icon propertyBookmarkTreeNode Rob W No, you cannot change the favicon

How to Refresh Bookmark Icons in Chrome

Pedwa I updated favicons for a bunch of my sites. Refreshing the site does indeed show the updated favicon in the browser tab, but the bookmarks for those sites still have the old favicon. Besides removing and re-adding each bookmark, is there any way to make

How to Refresh Bookmark Icons in Chrome

Pedwa I updated favicons for a bunch of my sites. Refreshing the site does indeed show the updated favicon in the browser tab, but the bookmarks for those sites still have the old favicon. Besides removing and re-adding each bookmark, is there any way to make

How can I tell which image Chrome's bookmark manager should use?

Priest In a seemingly random fashion, Chrome's "Bookmark Manager" will select the image it will use as the bookmarked page's thumbnail. In my case, it chose the worst on-page ad. How can I fiddle with other things, like pictures of people? Fodick There is no d

How can I tell which image Chrome's bookmark manager should use?

Priest In a seemingly random fashion, Chrome's "Bookmark Manager" will select the image it will use as the bookmarked page's thumbnail. In my case, it chose the worst on-page ad. How can I fiddle with other things, like pictures of people? Fodick There is no d

Chrome - How to Customize the "Add Bookmark" Popup

Cooperman I'm looking for a way to change and customize the standard popup that appears in Chrome to use every time I want to add a bookmark. This is the window I'm talking about: I've searched for dozens of extensions, all related to managing bookmarks in Chr

How to export a single bookmark folder in Google Chrome?

ACP In my bookmarks window, I have two or three folders like asp.netthat, jqueryand sql server. How to export folders jqueryonly from Google Chrome ? Baldwin The Data Liberation Front has a short statement about this: it appears to be possible to export bookma

How to get URL icon on bookmark - Google Chrome?

Laev I am using Google Chrome 62.0.3202.75 on Windows 7 64bit OS. For some reason I had to reinstall Windows 7. However, I backed up important settings and files from the system drive, including Google Chrome 's bookmarks file. Then I also installed google chr

Chrome - How to Customize the "Add Bookmark" Popup

Cooperman I'm looking for a way to change and customize the standard popup that appears in Chrome to use every time I want to add a bookmark. This is the window I'm talking about: I've searched for dozens of extensions, all related to managing bookmarks in Chr

How to export a single bookmark folder in Google Chrome?

ACP In my bookmarks window, I have two or three folders like asp.netthat, jqueryand sql server. How to export folders jqueryonly from Google Chrome ? Baldwin The Data Liberation Front has a short statement about this: it appears to be possible to export bookma

Chrome - How to Customize the "Add Bookmark" Popup

Cooperman I'm looking for a way to change and customize the standard popup that appears in Chrome to use every time I want to add a bookmark. This is the window I'm talking about: I've searched for dozens of extensions, all related to managing bookmarks in Chr

How to get URL icon on bookmark - Google Chrome?

Laev I am using Google Chrome 62.0.3202.75 on Windows 7 64bit OS. For some reason I had to reinstall Windows 7. However, I backed up important settings and files from the system drive, including Google Chrome 's bookmarks file. Then I also installed google chr

How to parse date value into SonarAPI call

Atlanta Falcons One of the calls from SonarAPI to get the value of the date 2018-12-13T18:04:42-0500, Now when trying to parse this date value into SonarAPI it fails with the following error: Invoke-RestMethod : { "errors": [ { "msg": "Date '$date

How to parse date value into SonarAPI call

Atlanta Falcons One of the calls from SonarAPI to get the value of the date 2018-12-13T18:04:42-0500, Now when trying to parse this date value into SonarAPI it fails with the following error: Invoke-RestMethod : { "errors": [ { "msg": "Date '$date

How to parse date with minutes contains value 60?

Kapil Gandhi I get exception when minute contains value 60 var date = "30/10/14 08:60"; var result = DateTime.ParseExact(date, "dd/MM/yy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None); How do I parse correctly? Local tycoon If you always know if t

How to parse date with minutes contains value 60?

Kapil Gandhi I get exception when minute contains value 60 var date = "30/10/14 08:60"; var result = DateTime.ParseExact(date, "dd/MM/yy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None); How do I parse correctly? Local tycoon If you always know if t