问题描述
我使用记事本打开Safari浏览器的History.plist文件,我发现访问的URL的编码日期时间是9位数+ DOT +一位数。我不知道如何将它解释为适合的日期时间格式,我希望将其更改为当前日期。
I open the History.plist file of Safari browser using a notepad and I find the encoded datetime of an accessed URL is 9 digits+DOT+one digit. I can't figure out how to interpret it to a suited datetime format, I wish to change it into the current date.
代码
DateTime dt=DateTime.FromOADate(348020617.0);
推荐答案
如果这是UNIX时间戳,那么可以转换使用此功能(借用)
If this is a UNIX timestamp, then you can convert using this function (borrowed from http://codeclimber.net.nz/archive/2007/07/10/convert-a-unix-timestamp-to-a-.net-datetime.aspx)
static DateTime ConvertFromUnixTimestamp(double timestamp)
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);
}
为什么值得,你提到的时间戳(348020617.0)转换为01 / 10/81 @ 6:23:37 pm EST
For what it's worth, that timestamp you mentioned (348020617.0) converts to 01/10/81 @ 6:23:37pm EST
这篇关于双向转换为日期时间总是失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!