PromptVault/resources/js/lib/format.js

26 lines
488 B
JavaScript
Raw Permalink Normal View History

2026-10-26 20:12:16 +00:00
/**
* Format an ISO date string for display.
*
* @param {string|null|undefined} value
* @returns {string}
*/
export function formatDate(value) {
if (!value) {
return '—';
}
const date = new Date(value);
if (Number.isNaN(date.getTime())) {
return String(value);
}
return date.toLocaleString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
});
}