Jinming Lv
Jinming Lv

Reputation: 123

How to convert epoch time to time_point

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"

Upvotes: 10

Views: 5760

Answers (1)

Howard Hinnant
Howard Hinnant

Reputation: 218860

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.

Upvotes: 15

Related Questions