Better simple date generation
This commit is contained in:
@@ -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]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user