21 lines
561 B
TypeScript
21 lines
561 B
TypeScript
// format the date to the format we want
|
|
export const formatDate = (date: Date): string => {
|
|
const year = date.getFullYear()
|
|
const month = (date.getMonth() + 1 + '').padStart(2, '0')
|
|
const day = (date.getDate() + '').padStart(2, '0')
|
|
return `${year}${month}${day}`
|
|
}
|
|
|
|
// get formated datestring of yesterday
|
|
export const yesterday = (date?: Date) => {
|
|
date = date || new Date()
|
|
date.setDate(date.getDate() - 1)
|
|
return date
|
|
}
|
|
|
|
export const nextday = (date?: Date) => {
|
|
date = date || new Date()
|
|
date.setDate(date.getDate() + 1)
|
|
return date
|
|
}
|