On this page
  1. gmtime
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

gmtime

Prev: strftime | Up: time.h | Next: asctime
Rel: time.h, math, time & assert Guide
Ref: cppreference — gmtime
Tags: #public #prog #c #stdlib #time #tier/standard


Include

#include <time.h>

Signature & Overview

struct tm *gmtime(const time_t *timer);  /* also localtime */

Converts time_t to UTC broken-down struct tm.

Notes & Pitfalls

Example

#include <assert.h>
#include <time.h>

int main(void) {
    time_t epoch = 0;
    struct tm *utc = gmtime(&epoch);
    assert(utc != NULL && utc->tm_year + 1900 == 1970);
}

Linked from

Related notes