Formats a time according to the specified timeStyle and locale.
timeStyle
Uses Intl.DateTimeFormat internally.
Intl.DateTimeFormat
formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "short" }); // "11:59 PM"formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "medium" }); // "11:59:59 PM"formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "long" }); // "11:59:59 PM EST"formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "full" }); // "11:59 PM Eastern Standard Time" Copy
formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "short" }); // "11:59 PM"formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "medium" }); // "11:59:59 PM"formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "long" }); // "11:59:59 PM EST"formatTime(new Date("2025-12-31T23:59:59"), { timeStyle: "full" }); // "11:59 PM Eastern Standard Time"
Optional
The date object or timestamp to extract the time from.
Options to customize time formatting.
A formatted time string.
Formats a time according to the specified
timeStyleand locale.Uses
Intl.DateTimeFormatinternally.Example Output