Get the time in ISO 8601 format
// Return the current local time in ISO 8601 format which includes
// the offset from UTC.
// i.e. 2019-09-27T13:51:30+01:00
std::string timeISO()
{
auto now = std::chrono::system_clock::now();
auto in_time_t = std::chrono::system_clock::to_time_t(now);
std::tm tm = *std::localtime(&in_time_t);
std::stringstream ss;
ss << std::put_time(&tm, "%FT%T%z");
return ss.str();
}
Comments