| NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUE | ATTRIBUTES | STANDARDS | HISTORY | SEE ALSO | COLOPHON | |
|  | 
ntp_gettime(3)           Library Functions Manual          ntp_gettime(3)
       ntp_gettime, ntp_gettimex  - get time parameters (NTP daemon
       interface)
       Standard C library (libc, -lc)
       #include <sys/timex.h>
       int ntp_gettime(struct ntptimeval *ntv);
       int ntp_gettimex(struct ntptimeval *ntv);
       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), 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) 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.
       The return values for ntp_gettime() and ntp_gettimex() are as for
       adjtimex(2).  Given a correct pointer argument, these functions
       always succeed.
       For an explanation of the terms used in this section, see
       attributes(7).
       ┌──────────────────────────────────────┬───────────────┬─────────┐
       │ Interface                            │ Attribute     │ Value   │
       ├──────────────────────────────────────┼───────────────┼─────────┤
       │ ntp_gettime(), ntp_gettimex()        │ Thread safety │ MT-Safe │
       └──────────────────────────────────────┴───────────────┴─────────┘
       ntp_gettime()
              NTP Kernel Application Program Interface.
       ntp_gettimex()
              GNU.
       ntp_gettime()
              glibc 2.1.
       ntp_gettimex()
              glibc 2.12.
       adjtimex(2), ntp_adjtime(3), time(7)
       NTP "Kernel Application Program Interface" 
       ⟨http://www.slac.stanford.edu/comp/unix/package/rtems/src/ssrlApps/ntpNanoclock/api.htm⟩
       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.15.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2025-08-11.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       man-pages@man7.org
Linux man-pages 6.15            2025-05-17                 ntp_gettime(3)
Pages that refer to this page: adjtimex(2), time(7)