Skip to content

Instantly share code, notes, and snippets.

@basp1
Created May 30, 2018 07:18
Show Gist options
  • Save basp1/d10d6bf06b73b0b8028caf51ae2dde51 to your computer and use it in GitHub Desktop.
Save basp1/d10d6bf06b73b0b8028caf51ae2dde51 to your computer and use it in GitHub Desktop.
std::chrono::time_point to std::string
#include <chrono>
#include <ctime>
#include <string>
static std::string toString(std::chrono::time_point<std::chrono::system_clock> time) {
static char buf[100];
std::time_t timeC = std::chrono::system_clock::to_time_t(time);
std::tm timeTm = *std::localtime(&timeC);
std::strftime(buf, 100, "%c", &timeTm);
return std::string(buf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment