Is there a way to get the ptime
representation of the current UTC time using boost Posix Time Library with nanoseconds precision? I know how to get microseconds precision using microsec_clock
. I know as well we can get this using chrono
:
#include <chrono>
#include <ctime>
const std::chrono::time_point<std::chrono::system_clock> pt = std::chrono::system_clock::now();
const auto nanos = static_cast<std::time_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(pt.time_since_epoch()).count());
Looking for something like nanosec_clock
maybe?
Note: I am using boost library so I would like to keep using it for this as well, if no solution I could use the chrono above explained here as well.
chrono
. That is the difference with that question. I added a Note in the question. Thank you