Search code examples
javascripttimestampunix-timestamp

How to convert "timestamp_usec"?


How can I convert a "timestamp_usec" number, such as 1364774098689591 to an actual date/time?

I downloaded my entire Google Search history. With each archived internet search (JSON File), Google includes a piece of meta-information called the "timestamp_usec."

I've found a few websites that do it for me, but I can't for the life of me find a JavaScript formula that will do it, or an explanation of how it's done.

I've found a few "unix timestamp" converters, but they don't seem to work on this "Timestamp_USEC," as it appears to be a different format.

Thanks!


Solution

  • It's not a "different format". It's just a conventional unix timestamp in microseconds, which means you can use the TRIVIAL conversion:

    var d = new Date(1364774098689591 / 1000);
    

    to load it up. JS Date() expects milliseconds (among other formats), and microseconds = milliseconds * 1000, after all...