---
name: "ntp_gettime"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ntp_gettime/3"
---

# ntp\_gettime(3)

get time parameters (NTP daemon interface)

## NAME

ntp\_gettime, ntp\_gettimex  - get time parameters (NTP daemon interface)

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <sys/timex.h>
```

**int ntp\_gettime(struct ntptimeval \****ntv***);** **int ntp\_gettimex(struct ntptimeval \****ntv***);**

## DESCRIPTION

Both of these APIs return information to the caller via the *ntv* argument, a structure of the following type:

```
struct ntptimeval {
    struct timeval time;    /* Current time */
    long maxerror;          /* Maximum error */
    long esterror;          /* Estimated error */
    long tai;               /* TAI offset */
    /* Further padding bytes allowing for future expansion */
};
```

The fields of this structure are as follows:

- *time*

  The current time, expressed as a *timeval* structure:

-

  ```
  struct timeval {
      time_t      tv_sec;   /* Seconds since the Epoch */
      suseconds_t tv_usec;  /* Microseconds */
  };
  ```

- *maxerror*

  Maximum error, in microseconds. This value can be initialized by [**ntp\_adjtime**(3)](/ntp_adjtime/3.md), and is increased periodically (on Linux: each second), but is clamped to an upper limit (the kernel constant **NTP\_PHASE\_MAX**, with a value of 16,000).

- *esterror*

  Estimated error, in microseconds. This value can be set via [**ntp\_adjtime**(3)](/ntp_adjtime/3.md) to contain an estimate of the difference between the system clock and the true time. This value is not used inside the kernel.

- *tai*

  TAI (Atomic International Time) offset.

**ntp\_gettime**() returns an *ntptimeval* structure in which the *time*, *maxerror*, and *esterror* fields are filled in.

**ntp\_gettimex**() performs the same task as **ntp\_gettime**(), but also returns information in the *tai* field.

## RETURN VALUE

The return values for **ntp\_gettime**() and **ntp\_gettimex**() are as for [**adjtimex**(2)](/adjtimex/2.md). Given a correct pointer argument, these functions always succeed.

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **ntp\_gettime**(), **ntp\_gettimex**() | Thread safety | MT-Safe |

## STANDARDS

- **ntp\_gettime**()

  NTP Kernel Application Program Interface.

- **ntp\_gettimex**()

  GNU.

## HISTORY

- **ntp\_gettime**()

  glibc 2.1.

- **ntp\_gettimex**()

  glibc 2.12.

## SEE ALSO

[**adjtimex**(2)](/adjtimex/2.md), [**ntp\_adjtime**(3)](/ntp_adjtime/3.md), [**time**(7)](/time/7.md)

NTP "Kernel Application Program Interface" ⟨http:\\://www.slac.stanford.edu/comp/unix/\\:package/\\:rtems/\\:src/\\:ssrlApps/\\:ntpNanoclock/\\:api.htm⟩
