The C date and time functions are a group of functions in the
standard library of the
C programming language
''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as ...
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, t ...
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++).
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 ...
*
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