C++11 – How to Convert Epoch Time to time_point

c++c++11

In some place I already get the epoch time value like this:

int64_t timeSeconds = std::chrono::duration_cast<std::chrono::seconds>(m_startTime.time_since_epoch()).count()

But how to convert this back to "std::chrono::system_clock::time_point"

Best Answer

std::chrono::system_clock::time_point tp{std::chrono::seconds{timeSeconds}};
  • Turn the integral type into seconds and then turn this duration into a time_point.
Related Question