I’m working with a date time picker component and having timezone issues when sending data to my API.
When I pick a date like “2025-05-04 15:30” in my picker, the console shows the right format:
Sun May 04 2025 15:30:00 GMT+0200 (Central European Summer Time)
But when I check the network requests, the time gets converted and shows up as:
begin_date: "2025-04-05T13:30:00.000Z"
There’s a 2 hour difference between what I selected and what gets sent. How do I make sure the original time value gets transmitted without timezone conversion?
const [beginDate, setBeginDate] = useState<DateValue | null>(new Date(schedule_data.begin_date));
const submitSchedule = async () => {
if(beginDate && finishDate) {
let scheduleEntries: TScheduleEntry[] = employees.map((employee) => {
return ({
employee_id: employee.id,
begin_date: beginDate,
finish_date: finishDate,
project_id,
active: true,
})
});
await createSchedule(scheduleEntries);
}
};
<DateTimePicker
className="mx-4"
defaultValue={beginDate}
clearable
placeholder="Select start time"
onChange={(value) => setBeginDate(value)}
/>