Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

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.

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.

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)

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top