The C date and time functions are a group of functions in the
standard library of the
C programming language implementing date and time manipulation operations. They provide support for
time
Time is the continued sequence of existence and events that occurs in an apparently irreversible succession from the past, through the present, into the future. It is a component quantity of various measurements used to sequence events, ...
acquisition, conversion between date formats, and formatted output to strings.
Overview of functions
The C date and time operations are defined in the
time.h
header file
Many programming languages and other computer files have a directive, often called include (sometimes copy or import), that causes the contents of the specified file to be inserted into the original file. These included files are called copybooks ...
(
ctime
header in
C++
C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
).
The and related types were originally proposed by Markus Kuhn to provide a variety of time bases, but only was accepted.
The functionalities were, however, added to C++ in 2020 in std::chrono.
Example
The following C source code prints the current time to the
standard output stream.
#include
#include
#include
int main(void)
The output is:
Current time is Thu Sep 15 21:18:23 2016
See also
*
Unix time
Current Unix time ()
Unix time is a date and time representation widely used in computing. It measures time by the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, the beginning of the Unix epoch, less adjustments m ...
*
Year 2038 problem
The year 2038 problem (also known as Y2038, Y2K38, or the Epochalypse) is a time formatting bug in computer systems with representing times after 03:14:07 UTC on 19 January 2038.
The problem exists in systems which measure Unix time â ...
References
External links
{{CProLang, state=expanded
C standard library
Time