我怎样才能在UTCTime以来毫秒在C语言中1970年1月1日, [英] How can i get UTCTime in milisecond since January 1, 1970 in c language
本文介绍了我怎样才能在UTCTime以来毫秒在C语言中1970年1月1日,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有什么办法让毫秒和c语言??
Is there any way to get miliseconds and its fraction part from 1970 using time.h in c language??
推荐答案
这适用于Ubuntu Linux操作系统:
This works on Ubuntu Linux:
struct timeval tv;
gettimeofday(&tv, NULL);
unsigned long long millisecondsSinceEpoch =
(unsigned long long)(tv.tv_sec) * 1000 +
(unsigned long long)(tv.tv_usec) / 1000;
printf("%llu\n", millisecondsSinceEpoch);
在写这篇文章时,printf()的时候上面是给我1338850197035.你可以在 TimestampConvert.com 完整性检查一>网站,你可以输入值取回相当于人类可读的时间(尽管没有毫秒precision)。
At the time of this writing, the printf() above is giving me 1338850197035. You can do a sanity check at the TimestampConvert.com website where you can enter the value to get back the equivalent human-readable time (albeit without millisecond precision).
这篇关于我怎样才能在UTCTime以来毫秒在C语言中1970年1月1日,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文