std::time (3) - Linux Manuals
std::time: std::time
Command to display std::time
manual in Linux: $ man 3 std::time
NAME
std::time - std::time
Synopsis
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.
Parameters
arg - pointer to a std::time_t object to store the time, or a null pointer
Return value
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.
Notes
The encoding of calendar time in std::time_t is unspecified, but most systems conform to POSIX_specification and return a value of integral type holding the number of seconds since the_Epoch. Implementations in which std::time_t is a 32-bit signed integer (many historical implementations) fail in the year 2038.
Example
// 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";
}
Output:
Wed Sep 21 10:27:52 2011
1316615272 seconds since the Epoch
See also
converts time since epoch to calendar time expressed as local time
localtime (function)
converts time since epoch to calendar time expressed as Universal Coordinated Time
gmtime (function)
system_clock wall clock time from the system-wide realtime clock
(class)
(C++11)
Pages related to std::time
- std::time_base (3) - std::time_base
- std::time_get (3) - std::time_get
- std::time_get<CharT,InputIt>::date_order,std::time_get<CharT,InputIt>::do_date_order (3) - std::time_get<CharT,InputIt>::date_order,std::time_get<CharT,InputIt>::do_date_order
- std::time_get<CharT,InputIt>::get,std::time_get<CharT,InputIt>::do_get (3) - std::time_get<CharT,InputIt>::get,std::time_get<CharT,InputIt>::do_get
- std::time_get<CharT,InputIt>::get_date,std::time_get<CharT,InputIt>::do_get_date (3) - std::time_get<CharT,InputIt>::get_date,std::time_get<CharT,InputIt>::do_get_date
- std::time_get<CharT,InputIt>::get_monthname, (3) - std::time_get<CharT,InputIt>::get_monthname,
- std::time_get<CharT,InputIt>::get_monthname,std::time_get<CharT,InputIt>::do_get_monthname (3) - std::time_get<CharT,InputIt>::get_monthname,std::time_get<CharT,InputIt>::do_get_monthname
- std::time_get<CharT,InputIt>::get_time,std::time_get<CharT,InputIt>::do_get_time (3) - std::time_get<CharT,InputIt>::get_time,std::time_get<CharT,InputIt>::do_get_time
- std::time_get<CharT,InputIt>::get_weekday,std::time_get<CharT,InputIt>::do_get_weekday (3) - std::time_get<CharT,InputIt>::get_weekday,std::time_get<CharT,InputIt>::do_get_weekday
- std::time_get<CharT,InputIt>::get_year,std::time_get<CharT,InputIt>::do_get_year (3) - std::time_get<CharT,InputIt>::get_year,std::time_get<CharT,InputIt>::do_get_year
- std::time_get<CharT,InputIt>::time_get (3) - std::time_get<CharT,InputIt>::time_get
- std::time_get<CharT,InputIt>::~time_get (3) - std::time_get<CharT,InputIt>::~time_get
- std::time_get_byname (3) - std::time_get_byname