Definition | #include <time.h> struct tm *gmtime(const time_t *sec_p);
The latest date which can be displayed with Warning If the POSIX "linkage option" library has not been linked with preference, it is not possible to get the result in UTC format. | |
Return val. | Pointer to the calculated structure. | |
struct tm { int tm_sec; /* seconds (0-59) */ int tm_min; /* minutes (0-59) */ int tm_hour; /* hours (0-23) */ int tm_mday; /* day of the month (1-31) */ int tm_mon; /* month from the start of the year (0-11) */ int tm_year; /* years since 1900 */ int tm_wday; /* weekday (0-6, 0=Sunday) */ int tm_yday; /* days since January 1 (0-365) */ int tm_isdst; /* daylight saving time flag */ }; | ||
NULL | In the event of an error | |
Notes |
| |
Example | #include <time.h> #include <stdio.h> struct tm *t; char *s; time_t clk; int main(void) { clk = time((time_t *)0); t = gmtime(&clk); printf("Year: %d\n", t->tm_year + 1900); printf("Time in hours: %d\n", t->tm_hour); printf("Day of the year: %d\n", t->tm_yday); s = asctime(t); printf("%s", s); return 0; } | |
See also | asctime, ctime, ctime64, localtime, localtime6 |