getTimePickerTime

Function

A utility method to get a time-picker time string in 24-hour format from a Date object, timestamp in ms, or a valid date/time string. By default, the time string will reflect the client's local time for the provided date. An optional IANA timeZone string can be provided to adjust the resulting time string to reflect the local time in the provided timeZone at that point in time.

getTimePickerTime('2024-03-29T17:00:00.000Z', 'America/New_York') // => 13:00:00 (eastern)

getTimePickerTime('2024-03-29T17:00:00.000Z', 'America/Los_Angeles') // => 10:00:00 (pacific)

  • getTimePickerTime(date: string | number | Date, timeZone: string) : string

Parameters

Parameter Type Default Notes
date Required string | number | Date

A Date object, timestamp in ms, or valid date/time string (e.g. 2024-03-29T16:00:00.000Z)

timeZone Optional string

An optional IANA time zone string, e.g. America/Los_Angeles

Returns

a time-picker time string in 24-hour format, e.g. 13:00:00

string

Function defined in common/src/utils/date/getTimePickerTime.ts:19