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

# TIMEVAL\_TO\_TIMESPEC(3)

convert between time structures

## NAME

TIMEVAL\_TO\_TIMESPEC, TIMESPEC\_TO\_TIMEVAL - convert between time structures

## SYNOPSIS

```
#define _GNU_SOURCE
#include <sys/time.h>
```

**void TIMEVAL\_TO\_TIMESPEC(const struct timeval \****tv***, struct timespec \****ts***);** **void TIMESPEC\_TO\_TIMEVAL(struct timeval \****tv***, const struct timespec \****ts***);**

## DESCRIPTION

These macros convert from a [**timeval**(3type)](/timeval/3type.md) to a [**timespec**(3type)](/timespec/3type.md) structure, and vice versa, respectively.

This is especially useful for writing interfaces that receive a type, but are implemented with calls to functions that receive the other one.

## STANDARDS

GNU, BSD.
