@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
18 lines (16 loc) • 491 B
JavaScript
import { nowInstant } from "../../internal/temporalCompat/clock.js";
// src/utc/get/getUtcHour.ts
/**
* Return the current hour from UTC as a zero-padded string.
*
* - Uses nowInstant() converted to UTC zoned date time.
* - Returns zero-padded string to 2 digits.
*
* @returns current hour string (zero-padded to 2 digits)
*
* @example getUtcHour() // "00"
*/
function getUtcHour() {
return nowInstant().toZonedDateTimeISO("UTC").hour.toString().padStart(2, "0");
}
export { getUtcHour };