gmtime_s
Go Up to time.h Index
Header File
time.h
Category
Time and Date Routines
Prototype
struct tm *gmtime(const time_t * _RESTRICT clock, struct tm * _RESTRICT result);
Description
Converts a calendar time to a UTC time.
gmtime_s does not allow tm or result to be null.
For more details on the tm structure, see gmtime.
Return Value
gmtime_s returns result if successful, or NULL otherwise.
Example
#include <stdio.h> #include <stdlib.h> #include <time.h> /* Pacific Standard Time & Daylight Savings */ char *tzstr = "TZ=PST8PDT"; int main(void) { time_t t; struct tm gmt, *area; putenv(tzstr); tzset(); t = time(NULL); area = localtime(&t); printf("Local time is: %s", asctime(area)); gmtime_s(&t, &gmt); printf("GMT is: %s", asctime(&gmt)); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |
+ |
+ |
+ |