Better simple date generation

This commit is contained in:
Eric Bailey
2024-06-18 16:37:04 -05:00
parent f49e115b26
commit 557d876ba1
+6 -5
View File
@@ -20,9 +20,10 @@ export function getAge(birthDate: Date): number {
return age return age
} }
export function toSimpleDateString(date: Date) { /**
const mm = date.getMonth() + 1 // 0-indexed * Returns date string in yyyy-MM-dd format
const dd = date.getDate() */
const yyyy = date.getFullYear() export function toSimpleDateString(date: Date | string): string {
return `${yyyy}-${mm}-${dd}` const _date = typeof date === 'string' ? new Date(date) : date
return _date.toISOString().split('T')[0]
} }