getUtcIn
Signature
Section titled “Signature”getUtcIn(units: Partial<Record<keyof DurationLike, number>>): stringReturn the UTC instant after now, as an ISO Instant string, counted from the current time.
- 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.- Lengths are unsigned: a negative amount returns "".
getUtcAgois the way back. { days: 0 }is a valid length and gives now.- Whole seconds, floored, always
Z, so every form of one call names the same second. A caller who wants sub-seconds writesaddUtc(getUtcNow(), units). - Calendar units count 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. For another zone’s wall clock, usegetZonedIn. - It feeds
formatHttpDate. A cookieExpiresisformatHttpDate(getUtcIn({ days: 90 })), and a past one that deletes the cookie isformatHttpDate(getUtcAgo({ days: 1 })): RFC 6265 §4.1.2 says servers can delete a cookie by sending one with anExpiresin the past (§3.1). - Each call reads the clock. To pin the start, use
addUtc(getUtcNow(), 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”ISO Instant string in whole seconds, or "" for invalid units, a negative amount or a result outside Temporal’s range
Related types
Section titled “Related types”Examples
Section titled “Examples”import { getUtcIn } from "@northguild/gmt/utc/get";
getUtcIn({ days: 90 }) // "2027-09-13T12:00:00Z" (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.