diff --git a/src/lib/strings/time.ts b/src/lib/strings/time.ts index b295c67765..6d71005dc8 100644 --- a/src/lib/strings/time.ts +++ b/src/lib/strings/time.ts @@ -20,9 +20,10 @@ export function getAge(birthDate: Date): number { return age } -export function toSimpleDateString(date: Date) { - const mm = date.getMonth() + 1 // 0-indexed - const dd = date.getDate() - const yyyy = date.getFullYear() - return `${yyyy}-${mm}-${dd}` +/** + * Returns date string in yyyy-MM-dd format + */ +export function toSimpleDateString(date: Date | string): string { + const _date = typeof date === 'string' ? new Date(date) : date + return _date.toISOString().split('T')[0] }