Skip to content

Instantly share code, notes, and snippets.

@misgeatgit
Created May 11, 2017 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misgeatgit/953f253a4b8a2fedc4ff0781285a21e2 to your computer and use it in GitHub Desktop.
Save misgeatgit/953f253a4b8a2fedc4ff0781285a21e2 to your computer and use it in GitHub Desktop.
print time_point
#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