且构网

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

如何在C ++中获取当前时间和日期?

更新时间:2022-10-27 12:49:07

std C库提供了一个跨平台的方法来获取当前日期和时间在C ++中? a href =http://en.cppreference.com/w/cpp/chrono/c/time =noreferrer> time()
这是从时代开始的秒数,可以使用标准C函数转换为日期和 H:M:S Boost 还有时间/日期库,你可以检查。

  time_t timev; 
时间(& timev);


Is there a cross-platform way to get the current date and time in C++?

std C libraries provide time(). This is seconds from the epoch and can be converted to date and H:M:S using standard C functions. Boost also has a time/date library that you can check.

time_t  timev;
time(&timev);