---
name: "timespec_get"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/timespec_get"
---

# timespec\_get(3)

get current calendar time

## NAME

**timespec\_get** – get current calendar time

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<time.h\>**

*int*\

**timespec\_get**(*struct timespec \*ts*, *int base*);

## DESCRIPTION

The **timespec\_get** function sets the interval pointed to by *ts* to hold the current calendar time based on the specified time base in *base*.

The base TIME\_UTC returns the time since the epoch. This time is expressed in seconds and nanoseconds since midnight (0 hour), January 1, 1970. In FreeBSD, this corresponds to CLOCK\_REALTIME.

The base TIME\_MONOTONIC returns a monotonically-increasing time since an unspecified point in the past. In FreeBSD, this corresponds to CLOCK\_MONOTONIC.

## RETURN VALUES

The **timespec\_get** function returns the passed value of *base* if successful, otherwise 0 on failure.

## SEE ALSO

[clock\_gettime(2)](/clock_gettime/2.md), [gettimeofday(2)](/gettimeofday/2.md), [time(3)](/time/3.md), [timespec\_getres(3)](/timespec_getres/3.md)

## STANDARDS

The **timespec\_get** function with a *base* of TIME\_UTC conforms to ISO/IEC 9899:2011 (“ISO C11”). The TIME\_MONOTONIC base conforms to ISO/IEC 9899:2024 (“ISO C23”).

## HISTORY

This interface first appeared in FreeBSD 12.

## AUTHORS

Kamil Rytarowski ⟨*kamil@NetBSD.org*⟩ Warner Losh ⟨*imp@FreeBSD.org*⟩
