开发者

Time Converter - time(NULL) to WINDOWS time

Is there a tool that converts the time(NULL) value to the WINDOWS time开发者_如何学编程.

The time(NULL) will give time in seconds since Jan 1, 1970. Now if i enter that value to this tool it must give me the time in date and hours, minutes and seconds.

In C++ we use the time(NULL) object a lot to send time.


See this KB from Microsoft, and chain with this function.


If by Windows time you mean the 64-bit time used in NTFS, you can use the conversion:

int64 wintime = 100000000uL * time(NULL) + 0x19db1ded53e8000uLL

where
   int64 is the type used by your compiler for 64-bit integers.

NT time is based on the origin at 1601-01-01 00:00:00 utc and counts ten million units per second—a timing precision of 100 ns. It assumes a simple leap year sequence and ignores the calendar complexities around 1752.

So, by multiplying the Unix time by ten million, and adding 116444736000000000 (decimal) or 0x19DB1DED53E8000, which is the difference between 1970-01-01 and 1601-01-01, one can easily convert from one to the other.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜