std::chrono::time_point<Clock,Duration>::time_since_epoch
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_since_epoch
(C++20)(C++20)
 Non-member functions
(until C++20)(C++20)
(C++17)
(C++17)
(C++17)
 Helper classes
(C++26)
duration time_since_epoch() const;
 
 (since C++11) (constexpr since C++14)
Returns a duration  representing the amount of time between *this and the clock's epoch.
[edit] Parameters
(none)
[edit] Return value
The amount of time between this time_point and the clock's epoch.
[edit] Example
Run this code
#include <chrono> #include <ctime> #include <iostream> int main() { const auto p0 = std::chrono::time_point <std::chrono::system_clock >{}; const auto p1 = std::chrono::system_clock::now (); const auto p2 = p1 - std::chrono::hours (24); std::time_t epoch_time = std::chrono::system_clock::to_time_t (p0); std::cout << "epoch: " << std::ctime (&epoch_time); std::time_t today_time = std::chrono::system_clock::to_time_t (p1); std::cout << "today: " << std::ctime (&today_time); std::cout << "hours since epoch: " << std::chrono::duration_cast <std::chrono::hours >( p1.time_since_epoch()).count() << '\n'; std::cout << "yesterday, hours since epoch: " << std::chrono::duration_cast <std::chrono::hours >( p2.time_since_epoch()).count() << '\n'; }
Possible output:
epoch: Thu Jan 1 00:00:00 1970 today: Fri Jun 30 10:44:11 2017 hours since epoch: 416338 yesterday, hours since epoch: 416314