diff --git a/frontend/app/api/listings/day/route.ts b/frontend/app/api/listings/day/route.ts index ccefca6..d588599 100644 --- a/frontend/app/api/listings/day/route.ts +++ b/frontend/app/api/listings/day/route.ts @@ -16,15 +16,14 @@ async function getListingsByDay(before?: string, after?: string) { // Normalize and format the dates const beforeDate = before ? new Date(before) : new Date(); beforeDate.setUTCHours(23, 59, 59, 999); - beforeDate.setDate(beforeDate.getDate() - 1); const afterDate = after ? new Date(after) : new Date(); afterDate.setUTCHours(0, 0, 0, 0); - afterDate.setDate(afterDate.getDate() - 1); const formattedBeforeDate = beforeDate.toISOString(); const formattedAfterDate = afterDate.toISOString(); console.log('formattedBeforeDate', formattedBeforeDate, 'formattedAfterDate', formattedAfterDate); + // formattedBeforeDate 2024-04-04T23:59:59.999Z formattedAfterDate 2024-03-05T00:00:00.000Z const results = await db.collection('listings').aggregate([ { diff --git a/frontend/components/dashboard/dashboard.tsx b/frontend/components/dashboard/dashboard.tsx index 9a9b7c6..1e965db 100644 --- a/frontend/components/dashboard/dashboard.tsx +++ b/frontend/components/dashboard/dashboard.tsx @@ -22,9 +22,12 @@ import DownloadCSV from "@/components/dashboard/DownloadCSV"; type Props = {}; export default function Dashboard({}: Props) { + const localTime = new Date(); + const today = new Date(localTime.getTime() + (localTime.getTimezoneOffset() * 60000)); + const [date, setDate] = useState({ - from: addDays(new Date(), -30), - to: new Date(), + from: addDays(today, -30), + to: today, }); return (