forked from UKSOURCE/hailearning.edu.vn
22 lines
494 B
TypeScript
22 lines
494 B
TypeScript
/**
|
||
* Format a date to `20 March 2025` style.
|
||
*
|
||
* Accepts:
|
||
* - ISO string: "2025-03-20T07:59:53.219Z"
|
||
* - "2025-03-20" or other Date‑parsable strings
|
||
* - Date instance
|
||
*/
|
||
export function formatLongDate(input: string | Date): string {
|
||
if (!input) return "";
|
||
|
||
const date = input instanceof Date ? input : new Date(input);
|
||
if (Number.isNaN(date.getTime())) return "";
|
||
|
||
return date.toLocaleDateString("en-GB", {
|
||
day: "numeric",
|
||
month: "long",
|
||
year: "numeric",
|
||
});
|
||
}
|
||
|