time.h — Time and date
time.h
header file declares the time and date functions:
asctime() | clock() | ctime() | difftime() | gmtime() |
localtime() | mktime() | strftime() | strptime() | time() |
tzset()1 | ||||
Note:
|
time.h
header file also provides: - A structure
timespec
that contains the following members:time_t tv_sec; seconds long tv_nsec; nanoseconds
- A structure
timespec64
that contains the following members:time64_t tv_sec; seconds long tv_nsec; nanoseconds
Note: In addition to the requirements for accessing structuretimespec
, feature test macro _LARGE_TIME_API is needed to exposetimespec64
. - A structure
tm
that contains the components of a calendar time. See Table 1 for a list of the members of thetm
structure. This structure is used by the functionsasctime()
,gmtime()
,localtime()
,mktime()
,strftime()
, andstrptime()
. - A macro
CLOCKS_PER_SEC
equal to the number per second of the value returned by theclock()
function. - Types
clock_t
,time_t
, andsize_t
. - The NULL pointer constant. For more information on NULL and the type
size_t
, see stddef.h — typedef statements. -
The macro CLK_TCK, which is the number of clock ticks per second, is kept for historical reasons. It was used in connection with the return value of the
clock()
function. CLK_TCK has been withdrawn and is not supported as part of Single UNIX Specification, Version 3. New applications should usesysconf(_SC_CLK_TCK)
instead of the CLK_TCK macro.However, if it is necessary to continue using this symbol in an application written for Single UNIX Specification, Version 3, define the feature test macro _UNIX03_WITHDRAWN before including any standard system headers. The macro exposes all interfaces and symbols removed in Single UNIX Specification, Version 3.
Field | Description |
---|---|
tm_sec | Seconds (0-60) |
tm_min | Minutes (0-59) |
tm_hour | Hours (0-23) |
tm_mday | Day of month (1-31) |
tm_mon | Month (0-11; January = 0) |
tm_year | Year (current year minus 1900) |
tm_wday | Day of week (0-6; Sunday = 0) |
tm_yday | Day of year (0-365; January 1 = 0) |
tm_isdst | Zero if Daylight Saving Time is not in effect; positive if Daylight Saving Time is in effect; negative if the information is not available. |
The time functions are affected by the current locale selected. The LC_CTYPE category affects the
behavior of the strftime()
, strptime()
, and
wcsftime()
functions. The LC_TOD category affects the behavior of the
gmtime()
, mktime()
, and localtime()
functions.