Skip to content

Commit a35072c

Browse files
committed
fix: helper date
1 parent 78f802d commit a35072c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/helpers/Date.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
import { format } from 'date-fns'
22
import { id } from 'date-fns/locale'
33

4-
const timezoneIndonesia = { locale: id }
4+
const TZ_ID = { locale: id } // Timezone Indonesia
55

66
const formatDate = (date: Date | number | string) => {
7-
return format(new Date(date), 'dd-MM-yyyy', timezoneIndonesia)
7+
return format(new Date(date), 'dd-MM-yyyy', TZ_ID)
88
}
99

1010
const formatDateTime = (date: Date | number | string) => {
11-
return format(new Date(date), 'dd-MM-yyyy HH:mm:ss', timezoneIndonesia)
11+
return format(new Date(date), 'dd-MM-yyyy HH:mm:ss', TZ_ID)
1212
}
1313

1414
const formatDateSystem = (date: Date | number | string) => {
15-
return format(new Date(date), 'yyyy-MM-dd', timezoneIndonesia)
15+
return format(new Date(date), 'yyyy-MM-dd', TZ_ID)
1616
}
1717

1818
const formatDateTimeSystem = (date: Date | number | string) => {
19-
return format(new Date(date), 'yyyy-MM-dd HH:mm:ss', timezoneIndonesia)
19+
return format(new Date(date), 'yyyy-MM-dd HH:mm:ss', TZ_ID)
2020
}
2121

2222
const formatMonth = (date: Date | number | string) => {
23-
return format(new Date(date), 'MMMM', timezoneIndonesia)
23+
return format(new Date(date), 'MMMM', TZ_ID)
2424
}
2525

2626
const formatYear = (date: Date | number | string) => {
27-
return format(new Date(date), 'yyyy', timezoneIndonesia)
27+
return format(new Date(date), 'yyyy', TZ_ID)
2828
}
2929

3030
const formatTime = (date: Date | number | string) => {
31-
return format(new Date(date), 'HH:mm:ss', timezoneIndonesia)
31+
return format(new Date(date), 'HH:mm:ss', TZ_ID)
3232
}
3333

3434
export {

0 commit comments

Comments
 (0)