1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <chrono>
int main() {
using namespace std::chrono;
// Define a duration of 5 seconds
seconds five_seconds(5);
// Define a duration of 2000 milliseconds
milliseconds two_thousand_ms(2000);
// Convert milliseconds to seconds
seconds converted = duration_cast<seconds>(two_thousand_ms);
std::cout << "5 seconds = " << five_seconds.count() << " seconds" << std::endl;
std::cout << "2000 milliseconds = " << converted.count() << " seconds" << std::endl;
return 0;
}
Back to std_chrono