diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index b23252e..02981bb 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -1252,7 +1252,15 @@ export const useCounterMixin = defineStore("mixin", () => { // กรณีมีเฉพาะ date function convertDateToAPI(date: Date | null) { - return date ? format(date, "yyyy-MM-dd") : null; + if (!date) return null; + + const parsedDate = new Date(date); + + if (parsedDate) { + return format(parsedDate, "yyyy-MM-dd"); + } else { + return null; + } } // กรณี datetime