<ctime>
The <ctime>
header is the C++ version of the C standard <time.h>
header, which declares types
and functions for working with dates and times.
The time_t
type is the
fundamental representation of a date and time. The details of this type
and how it encodes a date and time are implementation-defined. Unix
programmers recognize this type as the number of seconds since January
1, 1970, but that is only one possible implementation.
A date and time have a secondary representation as a tm
object, which breaks down a date and time
into constituent parts. The parts facilitate formatting dates and times
for output, or you can read a date and time, parse the parts, and build
a tm
object, which you can then
convert to a time_t
object.
This section describes the types and functions for working with dates and times. The Boost project has additional date and time classes. See Appendix B for information about Boost.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.