public member function
<chrono>

std::chrono::time_point::time_since_epoch

duration time_since_epoch() const;
Time since epoch
Returns a duration object with the time span value between the epoch and the time point.

The value returned is the current value of the internal duration object.

Parameters

none

Return value

The time span between the epoch and the time_point.
duration is a member type, defined as an alias of its second class template parameter (Duration), which is an instantiation of duration.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// time_point::time_since_epoch
#include <iostream>
#include <chrono>

int main ()
{
  using namespace std::chrono;

  system_clock::time_point tp = system_clock::now();
  system_clock::duration dtn = tp.time_since_epoch();

  std::cout << "current time since epoch, expressed in:" << std::endl;
  std::cout << "periods: " << dtn.count() << std::endl;
  std::cout << "seconds: " << dtn.count() * system_clock::period::num / system_clock::period::den;
  std::cout << std::endl;

  return 0;
}

Possible output:
current time since epoch, expressed in:
periods: 1338280396212871
seconds: 1338280396


See also