There are no notfications.

time.h

The time.h header provides functionality for date and time manipulation and conversion.

Type aliases

clock_t
Alias for __clock_t which is
alias for __CLOCK_T_TYPE which
expands to __SLONGWORD_TYPE which
expands to signed long int
Processor clock tick count.
size_t
See the stddef.h header.
time_t
Alias for __time_t which is
alias for __TIME_T_TYPE which
expands to __SLONGWORD_TYPE which
expands to signed long int
Calendar time since Unix epoch (00:00:00 UTC on 1 January 1970).

Macros

CLOCKS_PER_SEC
Expands to 1 000 000
clock_ts per second
Number of processor clock ticks per second.
TIME_UTC
Expands to 1
NULL
See the stddef.h header.

Types

tm
Time
Calendar date and time broken down into its components.
This data types is suitable for presentation and not calculation.
int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst;
timespec
Time specification
Time in seconds and nanoseconds.
time_t tv_sec; long tv_nsec;

Functions

Manipulation

clock_t clock(void);
Returns the processor time used by the program since it started.
If the processor time used is not available, −1 is returned.
double difftime(time_t time1, time_t time0);
Computes difference between two calender times and returns it.
time_t mktime(struct tm *timeptr);
Normalises calendar date and time broken down into its components and returns it as calendar time since Unix epoch (00:00:00 UTC on 1 January 1970).
If calendar time can not be represented, −1 is returned.
Categorically, this function performs both manipulation and conversion.
time_t time(time_t *timer);
Determines the current calendar time and returns it.
If *timer is not a null pointer, the determined value is assigned to it.
If calendar time is not available, −1 is returned.
int timespec_get(struct timespec *ts, int base);
Determines the current calendar time in the specified time base and assigns it to *ts.
Base will always be TIME_UTC for GCC/glibc.
If successful, base is returned, otherwise 0.

Conversion

char *asctime(const struct tm *timeptr);
Returns a char * (string) of a formatted tm *.
char *ctime(const time_t *timer);
Returns a char * (string) of a formatted time_t * in local time.
Equivalent to asctime(localtime(timer)).
struct tm *gmtime(const time_t *timer);
Returns a tm * representation of time_t * in UTC.
struct tm *localtime(const time_t *timer);
Returns a tm * representation of time_t * in local time.
size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);
Populates a char * (string) with a representation of tm * in a specified format.
Returns the number of resulting characters (including null character) placed into s *.
If the memory allocated for the string is too small, then 0 is returned.

External links