---
name: "libressl-X509_cmp_time"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-X509_cmp_time"
---

# libressl-X509\_cmp\_time(3)

ASN.1 Time utilities

## NAME

**X509\_cmp\_time**, **X509\_cmp\_current\_time**, **X509\_time\_adj\_ex**, **X509\_time\_adj**, **X509\_gmtime\_adj** – ASN.1 Time utilities

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/x509.h\>**

*int*\

**X509\_cmp\_time**(*const ASN1\_TIME \*asn1\_time*, *time\_t \*cmp\_time*);

*int*\

**X509\_cmp\_current\_time**(*const ASN1\_TIME \*asn1\_time*);

*ASN1\_TIME* *\**\

**X509\_time\_adj\_ex**(*ASN1\_TIME \*out\_time*, *int offset\_day*, *long offset\_sec*, *time\_t \*in\_time*);

*ASN1\_TIME* *\**\

**X509\_time\_adj**(*ASN1\_TIME \*out\_time*, *long offset\_sec*, *time\_t \*in\_time*);

*ASN1\_TIME* *\**\

**X509\_gmtime\_adj**(*ASN1\_TIME \*out\_time*, *long offset\_sec*);

## DESCRIPTION

**X509\_cmp\_time**() parses *asn1\_time* and compares it to *cmp\_time*, or to the current time if *cmp\_time* is NULL. **X509\_cmp\_current\_time**() compares it to the current time.

**X509\_time\_adj\_ex**() sets *out\_time* to a time *offset\_day* and *offset\_sec* later than *in\_time*. The values of *offset\_day* and *offset\_sec* can be negative to set a time before *in\_time*. The *offset\_sec* value can also exceed the number of seconds in a day. If *in\_time* is NULL, the current time is used instead. If *out\_time* is NULL, a new *ASN1\_TIME* structure is allocated and returned.

**X509\_time\_adj**() does the same with a 0 day offset.

**X509\_gmtime\_adj**() does the same using the current time instead of *in\_time*, that is, it sets *out\_time* to a time *offset\_sec* seconds later than the current time.

## RETURN VALUES

**X509\_cmp\_time**() and **X509\_cmp\_current\_time**() return -1 if *asn1\_time* is earlier than or equal to *cmp\_time*, 1 if it is later, or 0 on error.

**X509\_time\_adj\_ex**(), **X509\_time\_adj**(), and **X509\_gmtime\_adj**() return a pointer to the updated or newly allocated *ASN1\_TIME* structure or NULL on error.

## SEE ALSO

ASN1\_TIME\_new(3), ASN1\_TIME\_set(3), [time(3)](/time/3.md)

## HISTORY

**X509\_cmp\_current\_time**() and **X509\_gmtime\_adj**() first appeared in SSLeay 0.6.0 and have been available since OpenBSD 2.4.

**X509\_cmp\_time**() and **X509\_time\_adj**() first appeared in OpenSSL 0.9.6 and have been available since OpenBSD 2.9.

**X509\_time\_adj\_ex**() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9.
