Format
#include <time.h> struct tm *gmtime_r(const time_t *time, struct tm *result);
Language Level: XPG4
Threadsafe: Yes,
Description
This function is the restartable version of gmtime().
The gmtime_r() function breaks down the time value, in seconds, and stores it in result. result is a pointer to the tmstructure, defined in <time.h>. The value time is usually obtained by a call to the time() function.
The fields of the tm structure include:
Return Value
The gmtime_r() function returns a pointer to the resulting tm structure.
Notes:
Example that uses gmtime_r()
This example uses the gmtime_r() function to adjust a time_t representation to a Coordinated Universal Time character string, and then converts it to a printable string using the asctime_r() function.
#include <stdio.h> #include <time.h> int main(void) { time_t ltime; struct tm mytime; char buf[50]; time(<ime) printf ("Coordinated Universal Time is %s\n", asctime_r(gmtime_r(<ime, &mytime), buf)); } /************************ Output should be similar to: ********** Coordinated Universal Time is Wed Aug 18 21:01:44 1993 */
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.