time_t的时钟周期和获取时间问题



我正在尝试在我的简单 while 循环中获取当前的原始时间(不是人类可读的时间(。我搜索了time_t时钟周期,但找不到有关它的任何信息。

第一期:有谁知道C++time_t的时钟周期吗?

第 2 期:当我打印时间 ltime 时,它看起来一直都一样。

time_t ltime;
while (count <= 1000) {
time( & ltime); //I expect this to get current time in every cycle
cout << "Current time " << ltime << endl;
count++;
}

我已经检查了此链接,但它没有提供有关时钟周期的信息。

使用std::chrono::high_resolution_clock::now()

编辑:

使用std::system_clock::now()std::chrono::system_clock::to_time_t()

最新更新