std::chrono::time_point<Clock,Duration>::time_since_epoch (3) - Linux Manuals
std::chrono::time_point<Clock,Duration>::time_since_epoch: std::chrono::time_point<Clock,Duration>::time_since_epoch
Command to display std::chrono::time_point<Clock,Duration>::time_since_epoch
manual in Linux: $ man 3 std::chrono::time_point<Clock,Duration>::time_since_epoch
NAME
std::chrono::time_point<Clock,Duration>::time_since_epoch - std::chrono::time_point<Clock,Duration>::time_since_epoch
Synopsis
duration time_since_epoch() const; (since C++11)
(until C++14)
constexpr duration time_since_epoch() const; (since C++14)
Returns a duration representing the amount of time between *this and the clock's epoch.
Parameters
(none)
Return value
The amount of time between this time_point and the clock's epoch
Example
// Run this code
#include <iostream>
#include <chrono>
#include <ctime>
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
Pages related to std::chrono::time_point<Clock,Duration>::time_since_epoch
- std::chrono::time_point<Clock,Duration>::time_point (3) - std::chrono::time_point<Clock,Duration>::time_point
- std::chrono::time_point<Clock,Duration>::max (3) - std::chrono::time_point<Clock,Duration>::max
- std::chrono::time_point<Clock,Duration>::min (3) - std::chrono::time_point<Clock,Duration>::min
- std::chrono::time_point<Clock,Duration>::operator++, (3) - std::chrono::time_point<Clock,Duration>::operator++,
- std::chrono::time_point<Clock,Duration>::operator++,std::chrono::time_point<Clock,Duration>::operator-- (3) - - std::chrono::time_point<Clock,Duration>::operator++,std::chrono::time_point<Clock,Duration>::operator--
- std::chrono::time_point<Clock,Duration>::operator+,operator- (3) - - std::chrono::time_point<Clock,Duration>::operator+,operator-
- std::chrono::time_point (3) - std::chrono::time_point
- std::chrono::time_point_cast (3) - std::chrono::time_point_cast
- std::chrono::time_of_day (3) - std::chrono::time_of_day
- std::chrono::time_of_day<Duration>::hours,std::chrono::time_of_day<Duration>::minutes, (3) - std::chrono::time_of_day<Duration>::hours,std::chrono::time_of_day<Duration>::minutes,
- std::chrono::time_of_day<Duration>::make12,std::chrono::time_of_day<Duration>::make24 (3) - std::chrono::time_of_day<Duration>::make12,std::chrono::time_of_day<Duration>::make24
- std::chrono::time_of_day<Duration>::operatorprecision, (3) - std::chrono::time_of_day<Duration>::operatorprecision,
- std::chrono::time_of_day<Duration>::operatorprecision,std::chrono::time_of_day<Duration>::to_duration (3) - std::chrono::time_of_day<Duration>::operatorprecision,std::chrono::time_of_day<Duration>::to_duration
- std::chrono::time_of_day<Duration>::time_of_day (3) - std::chrono::time_of_day<Duration>::time_of_day
- std::chrono::time_zone (3) - std::chrono::time_zone
- std::chrono::time_zone::get_info (3) - std::chrono::time_zone::get_info
- std::chrono::time_zone::name (3) - std::chrono::time_zone::name
- std::chrono::time_zone::to_local (3) - std::chrono::time_zone::to_local
- std::chrono::time_zone::to_sys (3) - std::chrono::time_zone::to_sys
- std::chrono::tai_clock (3) - std::chrono::tai_clock