std::chrono example: Convert epoch timestamp to chrono & format as YYYY-mm-dd
double timestamp = 1675917638.773; // Example timestamp
// Convert timestamp to std::chrono::system_clock::time_point
auto tp = std::chrono::system_clock::from_time_t(static_cast<time_t>(timestamp));
std::time_t time = std::chrono::system_clock::to_time_t(tp);
std::tm tm = *std::localtime(&time);
// Format the std::tm to a string "YYYY-mm-dd"
std::ostringstream oss;
oss << std::put_time(&tm, "%Y-%m-%d");
std::string formatted_date = oss.str();
This prints 2023-10-09
for example.