【发布时间】:2022-08-14 07:46:25
【问题描述】:
我需要找出格式为YYYY DD MM HH MM SS MSC 的2 个时间戳的区别。
例如2022 08 13 08 17 20 512 和2022 08 13 08 17 20 000 的差异应该返回512 msec。
我浏览了https://stackoverflow.com/questions/9076494/how-to-convert-from-utc-to-local-time-in-c#:~:text=Or-,strptime(datetime%2C%20%22%25A%20%25B%20%25d%20%25,)%3B%20printtime%3Dctime(%3C)%3B 中的帖子。mktime 使用 struct tm pointer 可以代表直到 seconds 分辨率。
我们应该使用哪个函数来包含milliseconds 部分以及计算?我的测试系统有ubuntu 18.04 版本。
-
2 time stamps having format时间戳在哪个时区?has provision to represent till seconds resolution.soooo 自己处理秒数和毫秒数?我不明白。Which function should we use to include milliseconds portion as well for computation ?自己写一个?在mktime之后只是seconds * 1000 + milliseconds。How to get the difference of time stamps having milliseconds portion using C in Linux?以毫秒为单位表示时间。减去。 -
@KamilCuk 时间戳位于 UTC 时区。我在想如果任何系统功能已经可用,我可以使用它们。
-
are in UTC time zone所以记得在调用mktime之前设置时区。I was thinking if any system function is already available没有。对于 glibc,timersub对应于struct timeval。还有更好的struct timespec,但没有我知道的功能。
标签: linux time difference epoch