auto current_time = std::chrono::system_clock::now();
Using std::chrono
in C++
I get current time like above.
How can I use it to get the number of seconds since the clock's epoch as a double
?
time_since_epoch
can give you a duration since the clock's epoch (whatever the epoch may be):
auto current_time = std::chrono::system_clock::now();
auto duration_in_seconds = std::chrono::duration<double>(current_time.time_since_epoch());
double num_seconds = duration_in_seconds.count();