Created
May 11, 2017 05:10
-
-
Save misgeatgit/953f253a4b8a2fedc4ff0781285a21e2 to your computer and use it in GitHub Desktop.
print time_point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <chrono> | |
#include <ctime> | |
#include <iomanip> | |
#include <sstream> | |
#include <string> | |
using namespace std::chrono; | |
int main(){ | |
auto conv_time = [](time_point<system_clock> tpt){ | |
std::time_t t = system_clock::to_time_t(tpt); | |
std::stringstream ss; | |
std::tm tm = *std::localtime(&t); | |
ss << std::put_time(&tm, "%H:%M:%S") << '\n'; | |
return ss.str(); | |
}; | |
//set time_point to current time | |
auto time_point = system_clock::now(); | |
std::cout << conv_time(time_point) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment