Created
May 30, 2018 07:18
-
-
Save basp1/d10d6bf06b73b0b8028caf51ae2dde51 to your computer and use it in GitHub Desktop.
std::chrono::time_point to std::string
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 <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