##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# gmtime

From cppreference.com
< c‎ | chrono

Defined in header `<time.h>` |  |
tm* gmtime( const time_t* time ); |  |

Converts given time since epoch as time_t value into calendar time, expressed in Coordinated Universal Time (UTC).

### [edit] Parameters

time | - | pointer to a time_t object to convert

### [edit] Return value

pointer to a static internal tm object on success, or NULL otherwise. The structure may shared between gmtime, localtime, and ctime and may be overwritten on each invocation.

### [edit] Notes

This function may not be thread-safe.

POSIX requires that this function sets errno to EOVERFLOW if it fails because the argument is too large.

### [edit] Example

Run this code

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

    int main()
    {
        time_t t = time(NULL);
        printf("UTC:   %s", asctime(gmtime(&t)));
        printf("local: %s", asctime(localtime(&t)));

        return 0;
    }

Output:

    UTC:   Wed Oct  9 10:37:39 2013
    local: Wed Oct  9 17:37:39 2013

### [edit] See also

localtime | converts time since epoch to calendar time expressed as local time (function) [edit]
C++ documentation for gmtime

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/chrono/gmtime&oldid=65821"