# ISO date-time compare

`iso-datetime-compare` · version 1.0.0 · Dates & times (UTC, ISO 8601) · free, no key needed

Compare two strict UTC ISO-8601 datetimes and return -1, 0, or 1.

**Use when you need to: iso datetime compare · compare two utc datetimes · datetime ordering.**

## Supported

- iso datetime compare
- compare two utc datetimes
- datetime ordering

## Not supported

- leap seconds
- time zones
- offsets other than Z
- fractional seconds
- locale

## Behavior

- a and b must match YYYY-MM-DDTHH:MM:SSZ with zero-padded fields and a real proleptic Gregorian UTC civil time, years 0001-9999.
- Comparison is on the UTC millisecond timeline (Date.UTC / getUTC*, no local Date getters).
- Returns -1 if a is before b, 0 if equal, 1 if a is after b.

## Input

- `a` (string, required): min length 20; max length 20; pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`
- `b` (string, required): min length 20; max length 20; pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`

## Output

- `comparison` (one of -1, 0, 1, required)

## Limits

- min year: 1
- max year: 9999

## Example

Request input:

```json
{
  "a": "2026-09-15T12:00:00Z",
  "b": "2026-09-15T12:00:01Z"
}
```

Response:

```json
{
  "result": {
    "comparison": -1
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "iso-datetime-compare",
  "version": "1.0.0",
  "input": {
    "a": "2026-09-15T12:00:00Z",
    "b": "2026-09-15T12:00:01Z"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/iso-datetime-compare/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":"2026-09-15T12:00:00Z","b":"2026-09-15T12:00:01Z"}'
```

The machine-readable contract is at [/v1/tools/iso-datetime-compare/versions/1.0.0](/v1/tools/iso-datetime-compare/versions/1.0.0).

### CLI

```sh
node cli.mjs run iso-datetime-compare 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [ISO date compare](/tools/iso-date-compare): Compare two YYYY-MM-DD calendar dates and return -1, 0, or 1.
- [ISO date-time diff seconds](/tools/iso-datetime-diff-seconds): Return the signed whole-second difference between two strict UTC ISO-8601 datetimes.
- [ISO date-time add seconds](/tools/iso-datetime-add-seconds): Add a signed whole-second delta to a strict UTC ISO-8601 datetime.
- [ISO date-time clamp](/tools/iso-datetime-clamp): Clamp a strict UTC ISO-8601 datetime into an inclusive [min, max] range.
- [ISO date-time truncate](/tools/iso-datetime-truncate): Truncate a strict UTC ISO-8601 datetime toward UTC zero at day, hour, minute, or second.
- [Duration compare](/tools/duration-compare): Compare two SI duration amounts after converting both to nanoseconds.
