# formatHttpDateFromNow

:::caution[Unreleased]
Not in `@northguild/gmt` 1.20.0 on npm yet. It is on `main` and ships in the next release.
:::

## Signature

```ts
formatHttpDateFromNow(units: Partial<Record<keyof DurationLike, number>>): string
```

Return the RFC 9110 HTTP date (IMF-fixdate) after now, counted from the current time. It is the value for an `Expires` attribute or header.

- Reads the clock once, after `units` is checked.
- `units` is an object of unit amounts, such as `{ days: 90 }`. A duration string returns "". A fractional amount returns "": write `{ hours: 36 }` for a day and a half.
- `totalUnitsFromNow` gives the `Max-Age` that goes with it. When both are sent, `Max-Age` controls (RFC 6265 §4.1.2.2), so two separate clock reads do no harm. `ttlFromNow` gives both from one read.
- Lengths are unsigned: a negative amount returns "". A past date, the usual way to delete a cookie, is `formatHttpDate(getUtcAgo({ days: 1 }))`.
- Counts in UTC, so the result does not change with the server's zone, and a missing day clamps to the end of the month, as `addUtc` does. No 400-day cap is applied.
- Sub-second parts are dropped: IMF-fixdate has no sub-second field.
- Returns "" for a year outside 0000–9999 (IMF-fixdate's `year = 4DIGIT`).
- It equals `formatHttpDate(getUtcIn(units))`.
- Examples read the clock at 2027-06-15T12:00:00Z.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `units` | `Partial<Record<keyof DurationLike, number>>` | unit amounts, such as `{ days: 90 }`; never negative |

## Returns

RFC 9110 IMF-fixdate string, or "" for invalid `units`, a negative amount, a result outside Temporal's range or a year outside 0000–9999

## Related types

- [`DateTimeDurationUnit`](/gmt/reference/types/DateTimeDurationUnit)

## Examples

```ts
import { formatHttpDateFromNow } from "@northguild/gmt/utc/format";

formatHttpDateFromNow({ days: 90 }) // "Mon, 13 Sep 2027 12:00:00 GMT" (an expiry 90 days out)
```

## Source

[utc/format/formatHttpDateFromNow.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/utc/format/formatHttpDateFromNow.ts)
