📜  如何在 C++ 代码示例中读取计算机当前时间

📅  最后修改于: 2022-03-11 14:44:49.520000             🧑  作者: Mango

代码示例1
#include 
#include 
#include     

int main()
{
    auto start = std::chrono::system_clock::now();
    // Some computation here
    auto end = std::chrono::system_clock::now();

    std::chrono::duration elapsed_seconds = end-start;
    std::time_t end_time = std::chrono::system_clock::to_time_t(end);

    std::cout << "finished computation at " << std::ctime(&end_time)
              << "elapsed time: " << elapsed_seconds.count() << "s\n";
}