GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::chrono::time_point::time_since_epoch(3) C++ Standard Libary std::chrono::time_point::time_since_epoch(3)

std::chrono::time_point::time_since_epoch - std::chrono::time_point::time_since_epoch


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.


(none)


The amount of time between this time_point and the clock's epoch

// 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';
}


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

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.