Skip to content

formatHour

Formats only the hour component from a Luxon DateTime. Use it for hour labels in calendars, schedules, or chart axes.

Importing

ts
import { formatHour } from '@almighty-shogun/utils'

Usage

ts
import { DateTime } from 'luxon'
import { formatHour } from '@almighty-shogun/utils'

const hour = formatHour(DateTime.fromISO('2026-05-20T09:45:00'), 'en');

Parameters

NameTypeDescription
dateDateTimeDate to format.
localestringOptional locale override.

Returns

A localized hour string. Locale rules decide whether the result uses 12-hour or 24-hour formatting.

Type signature

ts
declare function formatHour(date: DateTime, locale?: string): string;

All packages are released under the MIT License.