gmtime_r
Go Up to time.h Index
Header File
time.h
Category
Time and Date Routines
Prototype
struct tm *gmtime_r( const time_t *timer, struct tm *buf );
Description
Converts a calendar time to a UTC time.
gmtime_r does not allow tm or result to be null.
For more details on the tm structure, see gmtime.
Return Value
gmtime_r returns result if successful, or NULL otherwise.
Example
#include <time.h>
#include <stdio.h>
#include <stdlib.h> // for putenv
int main()
{
time_t t = time(NULL);
struct tm tmbuf;
char buf[30];
printf("UTC: %s", asctime_r(gmtime_r(&t, &tmbuf), buf));
printf("local: %s", asctime_r(localtime_r(&t, &tmbuf), buf));
}
Portability
| POSIX | Win32 | ANSI C | ANSI C++ |
|---|---|---|---|
|
+ |
+ |
+ |
+ |