我可以在chrome.history.search查询中混合startTime和endTime吗? 所以我可以限制结果,例如。昨天?
这段代码给了我奇怪的结果(太多)
~/home/karaf/bin: ./karaf clean
答案 0 :(得分:3)
问题发生在当地时间 在调用history.search之前,我将时区偏移量添加到以ms为单位的搜索时间
//this is a global var and to be added to any timestamp in ms
var dateCurrent= new Date(),
correction = dateCurrent.getTimezoneOffset()*60*1000;
//now when calling history.search I'm calculating that correction in
//eg. for yestrday
var dN = Date.now(),
d1 = dN%86400000,
b = correction + dN - d1,
a = b - 86400000;
chrome.history.search({text:'', startTime: a, endTime:b, maxResults: 100000}, function {
//code
});
编辑:修正双重修正