---
name: "pmParseInterval"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pmParseInterval"
---

# pmParseInterval(3)

convert interval string to binary time structure

## NAME

**pmParseInterval** - convert interval string to binary time structure

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**

**int pmParseInterval(const char \****string***,** **struct timespec \****rslt***,** **char \*\****errmsg***);**

**cc ... -lpcp**

## DESCRIPTION

**pmParseInterval** parses the argument *string* specifying an interval of time and fills in the **tv\_sec** and **tv\_nsec** components of the *rslt* structure to represent that interval (nanosecond precision).

The input *string* is most commonly the argument following a **-t** command line option to a PCP application, and the syntax is fully described in [**PCPIntro**(1)](/PCPIntro/1.md).

## DIAGNOSTICS

**pmParseInterval** returns 0 and *errmsg* is undefined if the parsing is successful.

If the given *string* does not conform to the required syntax **pmParseInterval** returns -1 and a dynamically allocated error message string in *errmsg*. The error message is terminated with a newline and includes the text of the input *string* along with an indicator of the position at which the error was detected, e.g.\
 *4minutes 30mumble*\
            *^ -- unexpected value*

In the case of an error, the caller is responsible for calling [**free**(3)](/free/3.md) to release the space allocated for *errmsg*.

## COMPATIBILITY

Prior to PCP 7.0 the *rslt* argument was a `struct timeval`. To support PMAPI transition, the old interface and semantics can be used if applications are recompiled with **-DPMAPI\_VERSION=2**.

For a time in PCP 6.x there was a routine with the same semantics as the current **pmParseInterval** called **pmParseHighResInterval** although this is now deprecated and compile-time support for **pmParseHighResInterval** will be removed in a future release.

## SEE ALSO

[**PCPIntro**(1)](/PCPIntro/1.md), [**free**(3)](/free/3.md), [**PMAPI**(3)](/PMAPI/3.md) and [**pmParseTimeWindow**(3)](/pmParseTimeWindow/3.md).
