formatHttpDateFromNow
Signature
Section titled “Signature”formatHttpDateFromNow(units: Partial<Record<keyof DurationLike, number>>): stringReturn 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
unitsis checked. unitsis 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.totalUnitsFromNowgives theMax-Agethat goes with it. When both are sent,Max-Agecontrols (RFC 6265 §4.1.2.2), so two separate clock reads do no harm.ttlFromNowgives 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
addUtcdoes. 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
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
units | Partial<Record<keyof DurationLike, number>> | unit amounts, such as { days: 90 }; never negative |
Returns
Section titled “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
Section titled “Related types”Examples
Section titled “Examples”import { formatHttpDateFromNow } from "@northguild/gmt/utc/format";
formatHttpDateFromNow({ days: 90 }) // "Mon, 13 Sep 2027 12:00:00 GMT" (an expiry 90 days out)Source
Section titled “Source”Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else:© 2026 NorthGuild, all rights reserved.