15

I been working on parsing out bookmarks from an export file generated by google bookmarks. This file contains the following date attributes:

ADD_DATE="1231721701079000"

ADD_DATE="1227217588219000"

These are not standard unix style timestamps. Can someone point me in the right direction here? I'll be parsing them using c# if you are feeling like really helping me out.

Mike Glenn
  • 3,359
  • 1
  • 26
  • 33

9 Answers9

21

Chrome uses a modified form of the Windows Time format (“Windows epoch”) for its timestamps, both in the Bookmarks file and the history files. The Windows Time format is the number of 100ns-es since January 1, 1601. The Chrome format is the number of microseconds since the same date, and thus 1/10 as large.

To convert a Chrome timestamp to and from the Unix epoch, you must convert to seconds and compensate for the difference between the two base date-times (11644473600).

Here’s the conversion formulas for Unix, JavaScript (Unix in milliseconds), Windows, and Chrome timestamps (you can rearrange the +/× and -/÷, but you’ll lose a little precision):

u :  Unix       timestamp    eg: 1378615325
j :  JavaScript timestamp    eg: 1378615325177
c :  Chrome     timestamp    eg: 13902597987770000
w :  Windows    timestamp    eg: 139025979877700000

u =  (j / 1000)
u =  (c - 116444736000000)   / 10000000
u =  (w - 1164447360000000)  / 100000000

j =  (u * 1000)
j =  (c - 116444736000000)   / 10000
j =  (w - 1164447360000000)  / 100000

c =  (u * 10000000)          + 116444736000000
c =  (j * 10000)             + 116444736000000
c =  (w / 10)

w =  (u * 100000000)         + 1164447360000000
w =  (j * 100000)            + 1164447360000000
w =  (c * 10)

Note that these are pretty big numbers, so you’ll need to use 64-bit numbers or else handle them as strings like with PHP’s BC-math module.

Synetech
  • 9,643
  • 9
  • 64
  • 96
  • But the answer is about exported `bookmarks_mm.dd.yyyy.html` http://fileformats.archiveteam.org/wiki/Chrome_bookmarks – Alex78191 Dec 31 '17 at 03:36
  • I came here looking for chrome epoch to unix timestamp. The formula above didn't work for me. I tested with value for today (27 April 2018). `c = 13169330714873550`. Formula supplied above `u = (c - 116444736000000) / 10000000 => 2011-05-13...` Corrected formula `u = (c - 11644473600000000) / 1000000 => 2018-04-27...` – Michael Currin Apr 27 '18 at 20:17
8

In Javascript the code will look like this

function chromeDtToDate(st_dt) {
   var microseconds = parseInt(st_dt, 10);
   var millis = microseconds / 1000;
   var past = new Date(1601, 0, 1).getTime();
   return new Date(past + millis);
}
N. Alonso
  • 121
  • 1
  • 3
8

1231721701079000 looks suspiciously like time since Jan 1st, 1970 in microseconds.

perl -wle 'print scalar gmtime(1231721701079000/1_000_000)'
Mon Jan 12 00:55:01 2009

I'd make some bookmarks at known times and try it out to confirm.

Schwern
  • 153,029
  • 25
  • 195
  • 336
4

As of the newest Chrome Version 73.0.3683.86 (Official Build) (64-bit):

  • When I export bookmark, I got an html file like "bookmarks_3_22_19.html".
  • And each item has an 'add_date' field which contains date string. like this:
<a href="https://stackoverflow.com" add_date="1553220774" icon="">Stack Overflow</a>
  • This timestamp is actually seconds (not microseconds) since Jan 1st, 1970. So we can parse it with Javascript like following code:
function ChromeTimeToDate(timestamp) {
   var seconds = parseInt(timestamp, 10);
   var dt = new Date();
   dt.setTime(seconds * 1000);
   return dt;
}
  • For the upper example link, we can call ChromeTimeToDate('1553220774') to get Date.
ChromeTimeToDate('1553220774')
12:09:03.263 Fri Mar 22 2019 10:12:54 GMT+0800 (Australian Western Standard Time)
Speedoops
  • 126
  • 2
3

Eureka! I remembered having read the ADD_DATE’s meaning at some website, but until today, I could not find it again.

http://MSDN.Microsoft.com/en-us/library/aa753582(v=vs.85).aspx

offers this explanation as a “Note” just before the heading “Exports and Imports”:

“Throughout this file[-]format definition, {date} is a decimal integer that represents the number of seconds elapsed since midnight January 1, 1970.”

Before that, examples of {date} were shown:

<DT><H3 FOLDED ADD_DATE="{date}">{title}</H3> …

and

<DT><A HREF="{url}" ADD_DATE="{date}" LAST_VISIT="{date}" LAST_MODIFIED="{date}">{title}</A> …

Someday, I will write a VBA macro to convert these to recognizable dates, but not today!

If someone else writes a conversion script first, please share it. Thanks.

David
  • 15,894
  • 22
  • 55
  • 66
  • Not a macro, but it's what I just used, so here it is: double add_date = 1547960062; DateTime dt = new DateTime(1970, 1, 1); dt = dt.AddSeconds(add_date); – Adrian K Jan 20 '19 at 05:14
2

Initially looking at it, it almost looks like if you chopped off the last 6 digits you'd get a reasonable Unix Date using the online converter

1231721701 = Mon, 12 Jan 2009 00:55:01 GMT

1227217588 = Thu, 20 Nov 2008 21:46:28 GMT

The extra 6 digits could be formatting related or some kind of extended attributes.

There is some sample code for the conversion of Unix Timestamps if that is in fact what it is.

Rob Haupt
  • 2,104
  • 1
  • 15
  • 24
  • Schwern was correct, but I gave you a vote for the link which is the code I was using for converting unix timestamps. – Mike Glenn Feb 12 '09 at 04:25
1

look here for code samples: http://www.epochconverter.com/#code

// my groovy (java) code finally came out as:

def convertDate(def epoch)

{

    long dv = epoch / 1000; // divide by 1,000 to avoid milliseconds

    String dt = new java.text.SimpleDateFormat("dd/MMM/yyyy HH:mm:ss").format(new java.util.Date (dv));

   // to get epoch date: 

   //long epoch = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 01:00:00").getTime() * 1000;

    return dt;

} // end of def

So firefox bookmark date exported as json gave me:

json.lastModified :1366313580447014

convert from epoch date:18/Apr/2013 21:33:00

from :

println "convert from epoch date:"+convertDate(json.lastModified)
Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
jnorthr
  • 52
  • 6
0
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
0
#Python program

import time

d = 1630352263   #for example put here, if (ADD_DATE="1630352263")

print(time.ctime(d))  #Mon Aug 30 22:37:43 2021 - you will see
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
  • 1
    Please add further details to expand on your answer, such as working code or documentation citations. – Community Aug 31 '21 at 08:42