I am working on netscape cookies extractor and reader of chromium based browsers and when i tried , i got the value in webkit timestamp (17 digit value) 13332724148415168 , need a mathematical formula or a function to convert webkit timestamp to unix timestamp.
Asked
Active
Viewed 197 times
1
-
This value doesn't appear to be a valid JavaScript timestamp value. Do you know what it represents (seconds/milliseconds/nano-seconds since what epoch)? What is a WebKit Timestamp? Do you know what time this value should represent – phuzi Jul 06 '22 at 09:47
-
FYI Chromium doesn't use WebKit but Blink (which was forked from WebKit and, incidentally, why Safari is becoming the new IE) – phuzi Jul 06 '22 at 09:53
-
check this [DateTimeOffset](https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset?view=net-6.0). eg. `var timeStamp = DataTimeOffset.FromUnixTimeMilliseconds(time / 1000).ToUnixTimeSeconds()` – Parsa S Jul 06 '22 at 10:52
1 Answers
2
you can write your own method like the folowing:
static long WebKitTimestampToUnixSeconds(long webkitTimestamp)
{
const long secondsBetween19701601 = 11644473600; //Number of seconds between 1 Jan 1970 and 1 Jan 1601
//Divide by million to get seconds from WebKit timestamp and subtract seconds between 1 Jan 1970 and 1 Jan 1601
return webkitTimestamp / 1000000 - secondsBetween19701601;
}
Webkit uses a timestamp of microseconds since 1 Jan 1601 while Unix uses seconds between current date and 1 Jan 1970 then you have to:
- Convert Webkit timestamp to seconds by dividing it by 1 million
- Subtract delta seconds between 1 Jan 1970 and 1 Jan 1601 (11644473600)
You can test it here: https://www.epochconverter.com/webkit

ale91
- 316
- 3
- 8
-
For anyone that needs to convert to webkit epoch, its `(DateTimeOffset.UtcNow.ToUnixTimeSeconds() + secondsBetween19701601) * 1000000;` – denvercoder9 Sep 01 '23 at 21:55