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

date: DateTime
Date to format.

locale?: Undefinable<string>
Locale override.

Returns

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

Uses

Type signature

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

All packages are released under the MIT License.