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

std::time - std::time


Defined in header <ctime>
std::time_t time( std::time_t* arg );


Returns the current calendar time encoded as a std::time_t object, and also stores
it in the object pointed to by arg, unless arg is a null pointer.


arg - pointer to a std::time_t object to store the time, or a null pointer


Current calendar time encoded as std::time_t object on success, (std::time_t)(-1) on
error. If arg is not null, the return value is also stored in the object pointed to
by arg.


The encoding of calendar time in std::time_t is unspecified, but most systems
conform to the POSIX specification and return a value of integral type holding 86400
times the number of calendar days since the Epoch plus the number of seconds that
have passed since the last midnight UTC. Most notably, POSIX time does not (and can
not) take leap seconds into account, so that this integral value is not equal to the
number of S.I. seconds that have passed since the epoch, but rather is reduced with
the number of leap seconds that have occurred since the epoch. Implementations in
which std::time_t is a 32-bit signed integer (many historical implementations) fail
in the year 2038.

// Run this code


#include <ctime>
#include <iostream>


int main()
{
std::time_t result = std::time(nullptr);
std::cout << std::asctime(std::localtime(&result))
<< result << " seconds since the Epoch\n";
}


Wed Sep 21 10:27:52 2011
1316615272 seconds since the Epoch


timespec_get returns the calendar time in seconds and nanoseconds based on a given
(C++17) time base
(function)
localtime converts time since epoch to calendar time expressed as local time
(function)
converts time since epoch to calendar time expressed as Universal
gmtime Coordinated Time
(function)
system_clock wall clock time from the system-wide realtime clock
(C++11) (class)

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.