C++ Time Points

Time points, duration and literals.

Code to get the current time.

std::chrono::time_point now = std::chrono::system_clock::now();

The time_point is a class template, using a clock and a duration.

The system_clock we are using is based on the operating system's time.

Creating a specific date :

auto my_custom_date = std::chrono::year_month_day(std::chrono::year(2025), std::chrono::month(01), std::chrono::day(23));

Creating a time point

auto event = std::chrono::time_point<std::chrono::system_clock, std::chrono::days>(my_custom_date);