Last active
September 12, 2020 03:59
-
-
Save lindekaer/cbc0eafaedb064e1828b059b7af4ce11 to your computer and use it in GitHub Desktop.
Convert Google Chrome bookmark timestamp to JS date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Webkit timestamp is the number of microseconds from "1st of Jan 1601" | |
// The magic number 11644473600 is the number of seconds between | |
// "1st of Jan 1601" and "1st of Jan 1970" | |
export const converWebkitTimestamp = (webkitTimestamp: number): Date => { | |
const dateInSeconds = Math.round(webkitTimestamp / 1000000) - 11644473600 | |
return new Date(dateInSeconds * 1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment