30 Time library [time]

30.15 Header <ctime> synopsis [ctime.syn]

#define __STDC_VERSION_TIME_H__ 202311L #define NULL see [support.types.nullptr] #define CLOCKS_PER_SEC see below #define TIME_UTC see below #define TIME_MONOTONIC see below // optional #define TIME_ACTIVE see below // optional #define TIME_THREAD_ACTIVE see below // optional namespace std { using size_t = see [support.types.layout]; using clock_t = see below; using time_t = see below; struct timespec; struct tm; clock_t clock(); double difftime(time_t time1, time_t time0); time_t mktime(tm* timeptr); time_t timegm(tm* timeptr); time_t time(time_t* timer); int timespec_get(timespec* ts, int base); int timespec_getres(timespec* ts, int base); tm* gmtime(const time_t* timer); tm* gmtime_r(const time_t* timer, tm* buf); tm* localtime(const time_t* timer); tm* localtime_r(const time_t* timer, tm* buf); size_t strftime(char* s, size_t maxsize, const char* format, const tm* timeptr); }
The contents of the header <ctime> are the same as the C standard library header <time.h>.254
The functions gmtime and localtime are not required to avoid data races ([res.on.data.races]).
See also: ISO/IEC 9899:2024, 7.29
254)254)
strftime supports the C conversion specifiers C, D, e, F, g, G, h, r, R, t, T, u, V, and z, and the modifiers E and O.