且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

相当于 Windows 的 gettimeday()

更新时间:2022-06-23 05:32:32

GetLocalTime() 用于系统时区的时间,GetSystemTime() 用于 UTC.那些以 SYSTEMTIME 结构返回日期/时间,在那里它被解析为年、月等.如果你想要一个自纪元以来的秒数,请使用 SystemTimeToFileTime()GetSystemTimeAsFileTime().FILETIME 是一个 64 位值,自 UTC 时间 1601 年 1 月 1 日起间隔为 100ns.

GetLocalTime() for the time in the system timezone, GetSystemTime() for UTC. Those return the date/time in a SYSTEMTIME structure, where it's parsed into year, month, etc. If you want a seconds-since-epoch time, use SystemTimeToFileTime() or GetSystemTimeAsFileTime(). The FILETIME is a 64-bit value with the number of 100ns intervals since Jan 1, 1601 UTC.

对于间隔时间,使用GetTickCount().它返回自启动以来的毫秒数.

For interval taking, use GetTickCount(). It returns milliseconds since startup.

要以***分辨率(仅受硬件限制)获取间隔,请使用 QueryPerformanceCounter().

For taking intervals with the best possible resolution (limited by hardware only), use QueryPerformanceCounter().