### gmtime -- Convert Time

Format

>     #include <time.h>
>     struct tm *gmtime(const time_t *time);

Language Level: ANSI, POSIX, XPG4
The gmtime function breaks down the time value and stores it in a tm structure, defined in <time.h>.

The structure pointed to by the return value reflects Universal Coordinate Time (UTC), not local time. The value time is usually obtained from a call to time.

The fields of the tm structure include:

tm_sec | Seconds (0-61)
tm_min | Minutes (0-59)
tm_hour | Hours (0-23)
tm_mday | Day of month (1-31)
tm_mon | Month (0-11; January = 0)
tm_year | Year (current year minus 1900)
tm_wday | Day of week (0-6; Sunday = 0)
tm_yday | Day of year (0-365; January 1 = 0)
tm_isdst | Zero if Daylight Saving Time is not in effect; positive if Daylight Saving Time is in effect; negative if the information is not available.

Return Value
gmtime returns a pointer to the resulting tm structure.

On both OS/2 and Windows, it returns NULL if UTC is not available.

Notes:

1. The range (0-61) for tm_sec allows for as many as two leap seconds.
2. The gmtime and localtime functions may use a common, statically allocated buffer for the conversion. Each call to one of these functions may alter the result of the previous call.
3. Calendar time is the number of seconds that have elapsed since EPOCH, which is 00:00:00, January 1, 1970 Universal Coordinate Time.

On both OS/2 and Windows, the time and date functions begin at 00:00:00 Universal Coordinate Time, January 1, 1970, and do not have an upper limit.

Example
This example uses gmtime to adjust a time_t representation to an Universal Coordinate Time character string, and then converts it to a printable string using asctime.

    #include <stdio.h>
    #include <time.h>

    int main(void)
    {
       time_t ltime;

       time(&ltime);
       printf ("Universal Coordinate Time is %s\n",
                asctime(gmtime(&ltime)));
       return 0;

       /********************************************************
          The output should be similar to:

          Universal Coordinate Time is Mon Sep 16 21:44 1995
       ********************************************************/
    }

asctime -- Convert Time to Character String
ctime -- Convert Time to Character String
gmtime -- Convert Time
localtime -- Convert Time
mktime -- Convert Local Time
setlocale -- Set Locale
time -- Determine Current Time
<time.h>