- #include <iostream>
- #include <time.h>
- #include <sys/timeb.h>
- using namespace std;
- int main()
- {
- long long time_last;
- time_last = time(NULL);
- cout<<time_last<<endl; //秒数
- struct timeb t1;
- ftime(&t1);
- cout<<t1.time<<endl; //总秒数
- cout<<t1.time*1000 + t1.millitm<<endl; //总毫秒数
- system("pause");
- return 0;
- }
【整理】C++获得系统时间,以及1970年1月1日到现在的秒数、毫秒数
最新推荐文章于 2022-08-30 16:20:18 发布
本文详细介绍了在C++程序中使用time.h和sys/timeb.h库获取当前系统时间的方法,包括获取秒数、总秒数和总毫秒数,并通过实例演示了如何在程序中应用这些功能。
1万+

被折叠的 条评论
为什么被折叠?



