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

# difftime(3)

calculate time difference

## NAME

difftime - calculate time difference

## LIBRARY

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

## SYNOPSIS

```
#include <time.h>
```

**double difftime(time\_t** *time1***, time\_t** *time0***);**

## DESCRIPTION

The **difftime**() function returns the number of seconds elapsed between time *time1* and time *time0*, represented as a *double*. Each time is a count of seconds.

*difftime(b, a)* acts like *(b-a)* except that the result does not overflow and is rounded to *double*.

## ATTRIBUTES

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

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **difftime**() | Thread safety | MT-Safe |

## STANDARDS

C11, POSIX.1-2008.

## HISTORY

POSIX.1-2001, C89, SVr4, 4.3BSD.

## SEE ALSO

[**date**(1)](/date/1.md), [**gettimeofday**(2)](/gettimeofday/2.md), [**time**(2)](/time/2.md), [**ctime**(3)](/ctime/3.md), [**gmtime**(3)](/gmtime/3.md), [**localtime**(3)](/localtime/3.md)
