mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
Co-authored-by: James Player <james.player@portainer.io> Co-authored-by: Cara Ryan <cara.ryan@portainer.io> Co-authored-by: stevensbkang <skan070@gmail.com>
16 lines
365 B
TypeScript
16 lines
365 B
TypeScript
/**
|
|
* Format a date to a human-readable string based on the user's locale.
|
|
*/
|
|
export function localizeDate(date: Date) {
|
|
return date
|
|
.toLocaleString(undefined, {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
hour12: true,
|
|
})
|
|
.replace('am', 'AM')
|
|
.replace('pm', 'PM');
|
|
}
|