由网友(我比较没用)分享简介:如何转换蜱time_t的或FILETIME()?How do I convert ticks to time_t or filetime()?推荐答案time_t的是的定义为秒从Unix纪元日期1970年1月1日@ 00:00 UTC数。所以,你基本上需要弄清楚你的蜱多少时间再present和减去时代的时间。下...
如何转换蜱time_t的或FILETIME()?
How do I convert ticks to time_t or filetime()?
推荐答案
time_t的
是的定义为秒从Unix纪元日期1970年1月1日@ 00:00 UTC数。所以,你基本上需要弄清楚你的蜱多少时间再present和减去时代的时间。下面应该这样做。
time_t
is defined as the number of seconds from the Unix epoch date January 1, 1970 @ 00:00 UTC. So, you basically need to figure out how much time your ticks represent and subtract the epoch time. The following should do it.
double GetTimeTSecondsFrom(long ticks)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return (new DateTime(ticks) - epoch).TotalSeconds;
}
相关推荐
最新文章