fix(formatted date): show month and date with two digits

This commit is contained in:
Andrea 2024-10-01 13:46:53 +02:00
parent 919e8fd3eb
commit af931b764c
No known key found for this signature in database
GPG Key ID: 4594610B9C8F91C5

View File

@ -1,4 +1,6 @@
export function useFormattedDate(_date: string) {
const date = new Date(_date)
return `${date.getUTCFullYear()}/${date.getUTCMonth()}/${date.getUTCDate()}`
const date = new Date(_date);
const month = date.getUTCMonth().toString().padStart(2, "0");
const monthDate = date.getUTCDate().toString().padStart(2, "0");
return `${date.getUTCFullYear()}/${month}/${monthDate}`;
}