# Convert milliseconds, seconds, minutes and hours from an AI agent

You need to convert a time span between nanoseconds, microseconds, milliseconds, seconds, minutes, hours and days, for example 1500 ms to seconds.

Use `duration-convert@1.0.0`. It is free and needs no key or sign-up. Convert a canonical integer duration between nanosecond-based SI units as an exact rational.

## Why call a tool for this

The result is an exact fraction, so nothing is rounded away. For example, value 1500 from ms to s returns numerator 3 and denominator 2, which is 1.5 seconds.

## Call it over HTTP

```sh
curl -X POST https://computefirst.net/v1/tools/duration-convert/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"value":"90","from":"s","to":"min"}'
```

Response:

```json
{
  "result": {
    "numerator": "3",
    "denominator": "2"
  }
}
```

## Call it over MCP

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

```json
{
  "id": "duration-convert",
  "version": "1.0.0",
  "input": {
    "value": "90",
    "from": "s",
    "to": "min"
  }
}
```

## Check the result

The value must be a whole number written as a string. To convert 1.5 hours, convert 90 minutes instead, or multiply out the decimals first. Units are ns, us, ms, s, min, h and day; a day here is exactly 24 hours.

Full contract, limits and unsupported cases: [Duration convert](/tools/duration-convert).

## Related tools

- [Length convert](/tools/length-convert)
