How to get a std::chrono::time_point representing [now]?
In order to get a std::chrono::time_point<std::chrono::system_clock> representing the current point in time, use std::chrono::system_clock::now()
chrono_now_example.cpp
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();Typically, you would use auto to avoid having to type out (or read) the long typename of std::chrono::time_point<std::chrono::system_clock>:
chrono_now_auto.cpp
auto now = std::chrono::system_clock::now();Check out similar posts by category:
C/C++
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow