jeudi 12 décembre 2019

Get time_t from microseconds in the past

Working on a c++ 11 function that returns a string from an epoch timestamp with millisecond resolution. Doing this with the current date seems straight forward:

auto currentTime = std::chrono::system_clock::now( );
const time_t time = std::chrono::system_clock::to_time_t( currentTime );

However, I'm having a hard time finding out to initialize without now() and instead using a timestamp from the past. Trying to do this using std library, but can't quite see how to initialize the time_point using a past timestamp.

Aucun commentaire:

Enregistrer un commentaire