In c++:
How can I display the system current time (only time without the date) ?
How can I display current time + 3 minutes?
Can I do it using
cout
?
Which libraries or functions to use ?
In c++:
How can I display the system current time (only time without the date) ?
How can I display current time + 3 minutes?
Can I do it using cout
?
Which libraries or functions to use ?
You can try this example (use c++11 clang 3.6):
#include <iostream>
#include <iomanip>
#include <ctime>
#include <chrono>
int main()
{
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now - std::chrono::hours(24));
std::cout << std::put_time(std::localtime(&now_c), "%T") << std::endl;
std::time_t later_c = std::chrono::system_clock::to_time_t(now - std::chrono::hours(24) + std::chrono::minutes(3));
std::cout << std::put_time(std::localtime(&later_c), "%T") << std::endl;
return 0;
}
just use std::chrono
.