我一直在处理由谷歌书签生成的导出文件中的书签解析。该文件包含以下日期属性:
ADD_DATE="1231721701079000"
ADD_DATE="1227217588219000"
这些不是标准的Unix时间戳格式。有人可以指点我正确的方向吗?如果您愿意真正帮助我,我将使用c#对它们进行解析。
我一直在处理由谷歌书签生成的导出文件中的书签解析。该文件包含以下日期属性:
ADD_DATE="1231721701079000"
ADD_DATE="1227217588219000"
这些不是标准的Unix时间戳格式。有人可以指点我正确的方向吗?如果您愿意真正帮助我,我将使用c#对它们进行解析。
Chrome在书签文件和历史记录文件中使用了一种修改过的Windows时间格式(“Windows时代”)。 Windows时间格式是自1601年1月1日以来的100纳秒数。 Chrome格式是自同一日期以来的微秒数,因此小于Windows时间格式的十分之一。
要将Chrome时间戳转换为UNIX时间戳,并相互转换,必须先将其转换为秒,并补偿两个基准日期时间之间的差异(11644473600)。
下面是UNIX、JavaScript(毫秒级UNIX)、Windows和Chrome时间戳的转换公式(您可以重新排列+/-和×/÷,但会损失一些精度):
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)
请注意这些是非常大的数值,因此您需要使用64位数字或者像PHP的BC-math模块一样将它们处理为字符串。
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);
}
bookmarks_mm.dd.yyyy.html
的答案,不是关于 Bookmarks[.json]
的。 - Alex781911231721701079000 看起来很像自1970年1月1日以来的微秒数。
perl -wle 'print scalar gmtime(1231721701079000/1_000_000)'
Mon Jan 12 00:55:01 2009
我会在已知的时间点设置一些书签,并尝试测试以确认。
截至最新的Chrome版本73.0.3683.86(正式构建)(64位):
<a href="https://stackoverflow.com" add_date="1553220774" icon="">Stack Overflow</a>
function ChromeTimeToDate(timestamp) {
var seconds = parseInt(timestamp, 10);
var dt = new Date();
dt.setTime(seconds * 1000);
return dt;
}
ChromeTimeToDate('1553220774')
来获取日期。ChromeTimeToDate('1553220774')
12:09:03.263 Fri Mar 22 2019 10:12:54 GMT+0800 (Australian Western Standard Time)
一开始看起来,如果你去掉最后6位数字,使用在线转换器就可以得到一个合理的Unix日期。
1231721701 = 2009年1月12日星期一00:55:01 GMT
1227217588 = 2008年11月20日星期四21:46:28 GMT
额外的6位数字可能与格式相关或某种扩展属性有关。
如果确实是Unix时间戳,那么有一些Unix时间戳转换的示例代码。
在这里查看代码示例: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
json.lastModified :1366313580447014
convert from epoch date:18/Apr/2013 21:33:00
来自:
println "convert from epoch date:"+convertDate(json.lastModified)
#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
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)
bookmarks_mm.dd.yyyy.html
有关。http://fileformats.archiveteam.org/wiki/Chrome_bookmarks - Alex78191c = 13169330714873550
。上面提供的公式为u = (c - 116444736000000) / 10000000 => 2011-05-13...
更正后的公式为u = (c - 11644473600000000) / 1000000 => 2018-04-27...
- Michael Currin