---
name: "OPENSSL_gmtime"
section: "3ssl"
platform: "linux"
package: "openssl"
version: "3.6.5-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/OPENSSL_gmtime"
---

# OPENSSL\_gmtime(3ssl)

platform-agnostic OpenSSL time routines

## NAME

OPENSSL\_gmtime, OPENSSL\_gmtime\_adj, OPENSSL\_gmtime\_diff - platform-agnostic OpenSSL time routines

## SYNOPSIS

```
 #include <openssl/crypto.h>
 struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
 int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
 int OPENSSL_gmtime_diff(int *pday, int *psec,
                        const struct tm *from, const struct tm *to);
```

## DESCRIPTION

**OPENSSL\_gmtime()** returns the UTC time specified by *timer* into the provided *result* argument.

**OPENSSL\_gmtime\_adj()** adds the offsets in *offset\_day* and *offset\_sec* to *tm*.

**OPENSSL\_gmtime\_diff()** calculates the difference between *from* and *to*.

## NOTES

It is an error to call **OPENSSL\_gmtime()** with *result* equal to NULL. The contents of the time\_t given by *timer* are stored into the *result*. Calling with *timer* equal to NULL means use the current time.

**OPENSSL\_gmtime\_adj()** converts *tm* into a days and seconds value, adds the offsets, then converts back into a *struct tm* specified by *tm*. Leap seconds are not considered.

**OPENSSL\_gmtime\_diff()** calculates the difference between the two *struct tm* structures *from* and *to*. The difference in days is placed into *\*pday*, the remaining seconds are placed to *\*psec*. The value in *\*psec* will be less than the number of seconds per day (3600). Leap seconds are not considered.

## RETURN VALUES

**OPENSSL\_gmtime()** returns NULL on error, or *result* on success.

**OPENSSL\_gmtime\_adj()** and **OPENSSL\_gmtime\_diff()** return 0 on error, and 1 on success.

## HISTORY

**OPENSSL\_gmtime()**, **OPENSSL\_gmtime\_adj()** and **OPENSSL\_gmtime\_diff()** have been in OpenSSL since 1.0.0.

## COPYRIGHT

Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License").  You may not use this file except in compliance with the License.  You can obtain a copy in the file LICENSE in the source distribution or at \<https://www.openssl.org/source/license.html\>.
