std::chrono::time_point<Clock,Duration>::time_point
From cppreference.com
 
 
 < cpp | chrono | time point 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Date and time library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++11)
(C++20)
  (C++20)
(C++11)
(C++11)
(C++11)
(C++20)
(C++20)
(C++20)
(C++11)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
  (C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
std::chrono::time_point 
 
 
 
 
 
 
 
 Member functions
time_point::time_point
(C++20)(C++20)
 Non-member functions
(until C++20)(C++20)
(C++17)
(C++17)
(C++17)
 Helper classes
(C++26)
 
 (1)
 
time_point();
 
 (since C++11) (constexpr since C++14)
 
 (2)
 
explicit time_point( const duration& d );
 
 (since C++11) (constexpr since C++14)
 
 (3)
 
template< class Duration2 >
time_point( const time_point<Clock, Duration2>& t );
 
 (since C++11) time_point( const time_point<Clock, Duration2>& t );
(constexpr since C++14)
Constructs a new time_point from one of several optional data sources.
1) Default constructor, creates a 
time_point representing the Clock's epoch (i.e., time_since_epoch()  is zero).2) Constructs a 
time_point at Clock's epoch plus d.3) Constructs a 
time_point by converting t to duration. This constructor only participates in overload resolution if Duration2 is implicitly convertible to duration.[edit] Parameters
 d
 -
 a 
duration to copy from
 t
 -
 a 
time_point to convert from
[edit] Example
Run this code
#include <chrono> #include <iostream> using Clock = std::chrono::steady_clock ; using TimePoint = std::chrono::time_point <Clock>; void print_ms(const TimePoint& point) { using Ms = std::chrono::milliseconds ; const Clock::duration since_epoch = point.time_since_epoch(); std::cout << std::chrono::duration_cast <Ms>(since_epoch) << '\n'; } int main() { const TimePoint default_value = TimePoint(); // (1) print_ms(default_value); // 0ms const Clock::duration duration_4_seconds = std::chrono::seconds (4); const TimePoint time_point_4_seconds(duration_4_seconds); // (2) // 4 seconds from start of epoch print_ms(time_point_4_seconds); // 4000ms const TimePoint time_point_now = Clock::now(); // (3) print_ms(time_point_now); // 212178842ms }
Possible output:
0ms 4000ms 212178842ms