Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

How do I read computer current time in c++

#include <iostream>
#include <chrono>
#include <ctime>    

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

    std::chrono::duration<double> 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
";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #I #read #computer #current #time
ADD COMMENT
Topic
Name
6+9 =