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::system_clock::to_time_t(3) C++ Standard Libary std::chrono::system_clock::to_time_t(3)

std::chrono::system_clock::to_time_t - std::chrono::system_clock::to_time_t


static std::time_t to_time_t( const time_point& t ) noexcept; (since C++11)


Converts t to a std::time_t type.


If std::time_t has lower precision, it is implementation-defined whether the value
is rounded or truncated.


t - system clock time point to convert


A std::time_t value representing t.


Get the current time as a std::time_t two ways.

// Run this code


#include <iostream>
#include <ctime>
#include <chrono>
#include <thread>
using namespace std::chrono_literals;


int main()
{
// The old way
std::time_t oldt = std::time(nullptr);


std::this_thread::sleep_for(2700ms);


// The new way
std::time_t newt = std::chrono::system_clock::to_time_t(
std::chrono::system_clock::now());


std::cout << "oldt-newt == " << oldt-newt << " s\n";
}


oldt-newt == -3 s


from_time_t converts std::time_t to a system clock time point
[static] (public static member function)

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.