Files
threshold-ui/ui/admin/tests/helpers/format-date-user-friendly.js
T
Priya Patel 1780077068 Replace time element with Hds::Time component (#3112)
* refactor: 💡 use Hds::Time component

* refactor: 💡 fix data test selector

* refactor: 💡 standardardized date/time format

* refactor: 💡 fix tests and remove date helpers

* fix: 🐛 fixed helper test import
2026-02-02 18:52:19 -06:00

23 lines
524 B
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
/**
* Formats a date string into a user-friendly date/time format.
* Example: Jan 1, 2024, 12:00:00 AM GMT
* @param {date string} value
* @returns
*/
export const formatDateUserFriendly = (value) =>
new Intl.DateTimeFormat('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: '2-digit',
second: '2-digit',
hour12: true,
timeZoneName: 'short',
}).format(new Date(value));