Merge pull request 'efril' (#1) from efril into main
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
+15
-1
@@ -34,9 +34,23 @@ export const formatDate = (dateString: any) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const formatDateDDMMYYYY = (date: Date) => {
|
||||
export const formatDateDDMMYYYY = (dateString: Date | string) => {
|
||||
const date = new Date(dateString)
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const year = date.getFullYear()
|
||||
return `${day}-${month}-${year}`
|
||||
}
|
||||
|
||||
export const formatDatetime = (dateString: string | number | Date) => {
|
||||
const date = new Date(dateString)
|
||||
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const month = date.toLocaleString('id-ID', { month: 'long' }) // Aug
|
||||
const year = date.getFullYear()
|
||||
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
|
||||
return `${day} ${month} ${year} ${hours}:${minutes}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user