Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <time.h>
struct tm *gmtime(const time_t *timer);
#define _LARGE_TIME_API
#include <time.h>
struct tm *gmtime64(const time64_t *timer);
Converts the calendar time pointed to by timer into a broken-down time, expressed as Coordinated Universal Time (UTC).
1The value pointed to by timer is usually obtained by a call to the time() function.
The relationship between a time in seconds since the Epoch used as an argument to gmtime() and the tm structure (defined in the <time.h> header) is that the result is as specified in the expression given in the definition of seconds since the Epoch, where the names in the structure and in the expression correspond.
The function gmtime64() will behave exactly like gmtime() except it will break down a time64_t value pointing to a calendar time beyond 03:14:07 UTC on January 19, 2038 with a limit of 23:59:59 UTC on December 31, 9999.
Returns a pointer to a tm structure containing the broken-down time, expressed in Coordinated Universal Time (UTC) corresponding to calendar time pointed to by timer. The fields in tm are shown in Table 1. If the calendar time pointed to by timer cannot be converted to broken-down time (in UTC), gmtime() returns a NULL pointer.
⁄* CELEBG23
This example uses the &gmtime. function to convert a
time_t representation to a Coordinated Universal Time
character string and then converts it to a printable string
using &asct..
*⁄
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t ltime;
time(<ime);
printf ("Coordinated Universal Time is %s\n",
asctime(gmtime(<ime)));
}
Coordinated Universal Time (UTC) is Fri Jun 16 21:01:44 2001