在Firefox中将place.sqlite文件中的日期转换为DateTime

Gar*_*ett 4 c# sqlite firefox datetime

我在将存储浏览器历史记录的文件中找到的日期转换为正常的DateTime时遇到麻烦。

该文件位于:C:\ Users [用户名] \ AppData \ Roaming \ Mozilla \ Firefox \ Profiles [配置文件名称] \ places.sqlite

有问题的表格是:[moz_places]

该列为:[last_visit_date]


我已经尝试过使用unix纪元和webkit格式(例如chrome使用),但是都没有给我期望的结果。

这是我的Unix转换(不起作用):

    public static DateTime FromUnixTime(long unixTime)
    {
        var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
        return epoch.AddSeconds(unixTime);
    }
Run Code Online (Sandbox Code Playgroud)

这是我的Webkit转换代码:(也不适用于这些日期,它适用于Chromes Webkit日期)

    public static DateTime ConvertWebkitTimeToDateTime(long ticks)
    {
        //Set up a date at the traditional starting point for unix time.
        DateTime normalDate = new DateTime(1970, 1, 1, 0, 0, 0, 0);
        //Subtract the amount of seconds from 1601 to 1970.
        long convertedTime = (ticks - 11644473600000000);
        //Devide by 1000000 to convert the remaining time to seconds.
        convertedTime = convertedTime / 1000000;
        //Add the seconds we calculated above.
        normalDate = normalDate.AddSeconds(convertedTime);
        //Finally we have the date.
        return normalDate;
    }
Run Code Online (Sandbox Code Playgroud)

那么,Firefox存储这些日期有何处理?这是几个样本日期,应该全部在今天或昨天左右。(大约10/17/2013)

1373306583389000

1373306587125000

1373306700392000

任何帮助或文档链接都很棒,谢谢。

CL.*_*CL. 6

Unix时间戳以秒为单位。这些值大了百万分之一,即它们使用的是微秒:

> select datetime(1373306583389000 / 1000000, 'unixepoch');
2013-07-08 18:03:03
Run Code Online (Sandbox Code Playgroud)