Utilities

Format Time

Formats a given date into a time string based on the specified format, locale, and time zone.

Logo

Parameters

date

Type:

Date

The date or timestamp to format.

Default:

format

Type:

"hh:mm" | "hh:mm:ss" | "hh:mm AM/PM" | "hh:mm:ss AM/PM"

The time format pattern.

Default:

hh:mm
locale

Type:

"en-US" | "en-GB" | "en-CA" | "en-AU" | "en-IN" | "en-NZ" | "en-ZA" | "fr-FR" | "fr-CA" | "de-DE" | "es-ES" | "es-MX" | "it-IT" | "nl-NL" | "pt-PT" | "pt-BR" | "ru-RU" | "pl-PL" | "zh-CN" | "zh-TW" | "ja-JP" | "ko-KR" | "hi-IN" | "th-TH" | "vi-VN" | "ar-SA" | "he-IL" | "tr-TR" | "fa-IR"

The locale for formatting.

Default:

en-US
replaceFormat

Type:

"" | "-" | "/" | " " | "," | ":"

Replaces delimiters in the formatted time with a custom string.

Default:

timeZone

Type:

"UTC" | "PST" | "EST" | "CST" | "MST" | "IST" | "GMT" | "CET" | "EET" | "JST" | "AEST" | "AKST" | "HST" | "AST" | "NST" | "SST" | "CHST" | "BST" | "WET" | "EAT" | "MSK" | "SAMT" | "PKT" | "ICT" | "SGT" | "CST-China" | "KST" | "AEDT" | "NZST" | "FJT" | "HKT"

The time zone to use for formatting.

Default: